[issue4328] "à" in u"foo" raises a misleading error

Matthew Barnett report at bugs.python.org
Sat Nov 15 18:37:46 CET 2008


Matthew Barnett <python at mrabarnett.plus.com> added the comment:

The left operand is a bytestring and the right operand is a unicode
string, so it makes sense that it raises an exception, although it would
be clearer if it said "'in <string>' requires unicode string as left
operand".

I agree that if it's going to do implicit decoding so that it'll accept
'f' in u'foo' then it should probably raise a UnicodeDecodeError when
that fails.

If it's reporting a /TypeError/ then it should also reject 'f' in u'foo'.

----------
nosy: +mrabarnett

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4328>
_______________________________________


More information about the Python-bugs-list mailing list