Issue 1680159: Misleading exception from unicode.contains (original) (raw)

Hello Folks,

unicode.contains throws:

'\xff' in u'foo' Traceback (most recent call last): File "", line 1, in TypeError: 'in ' requires string as left operand

while:

Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)

would be more helpful, because that's what really fails there. The exception it throws now does not indicate that unicode is involved.

(tried this with 2.4.4 and 2.5.0 and happens in both)