STINNER Victor added the comment:

'AB\xff'.encode('ascii') raises a UnicodeDecodeError because the byte string 
'AB\xff' is decoded from the default encoding (sys.getdefaultencoding(), which 
is 'ASCII' in most cases), before  the .encode() method is called.

This is not a Python bug, but it is surprising. You should try Python 3 which 
does not have implicit conversion from/to bytes/unicode.

nosy: +haypo
resolution:  -> invalid
status: open -> closed

Python tracker <>
Python-bugs-list mailing list

Reply via email to