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 recent call last): File "<pyshell#27>", line 1, in <module> 'AB\xff'.encode('ascii') UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 2: ordinal not in range(128) ---- unicode string: >>> u'AB\xff'.encode('ascii') Traceback (most recent call last): File "<pyshell#28>", line 1, in <module> u'AB\xff'.encode('ascii') UnicodeEncodeError: 'ascii' codec can't encode character u'\xff' in position 2: ordinal not in range(128) ---------- components: Unicode messages: 175404 nosy: Wojtek.Szymilowski, ezio.melotti priority: normal severity: normal status: open title: UnicodeDecodeError thrown for 'encode' operation on string type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16456> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com