[issue16456] UnicodeDecodeError thrown for 'encode' operation on string

2012-11-17 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- stage: - committed/rejected ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16456 ___ ___

[issue16456] UnicodeDecodeError thrown for 'encode' operation on string

2012-11-11 Thread Wojtek Szymilowski
New submission from Wojtek Szymilowski: UnicodeDecodeError exception is reported for encode operation on strings. This issue does not surface for the same operation on unicode string (UnicodeEncodeError exception is correctly reported). string: 'AB\xff'.encode('ascii') Traceback (most

[issue16456] UnicodeDecodeError thrown for 'encode' operation on string

2012-11-11 Thread STINNER Victor
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