[issue6108] unicode(exception) behaves differently on Py2.6 when len(exception.args) 1
Changes by Georg Brandl ge...@python.org: -- priority: high - release blocker ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6108 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6108] unicode(exception) behaves differently on Py2.6 when len(exception.args) 1
Antoine Pitrou pit...@free.fr added the comment: Looks like a potentially annoying bug to me. -- nosy: +pitrou priority: - high stage: - needs patch versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6108 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6108] unicode(exception) behaves differently on Py2.6 when len(exception.args) 1
Changes by Chris Rebert pyb...@rebertia.com: -- nosy: +cvrebert ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6108 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6108] unicode(exception) behaves differently on Py2.6 when len(exception.args) 1
Jean-Paul Calderone exar...@divmod.com added the comment: Perhaps also worth noting is that in Python 2.4 as well, str(exception) and unicode(exception) returned the same thing. Unlike some other exception changes in 2.6, this doesn't seem to be a return to older behavior, but just a new behavior. (Or maybe no one cares about that; just wanted to point it out, though.) -- nosy: +exarkun ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6108 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6108] unicode(exception) behaves differently on Py2.6 when len(exception.args) 1
New submission from Ezio Melotti ezio.melo...@gmail.com: On Python 2.5 str(exception) and unicode(exception) return the same text: err UnicodeDecodeError('ascii', '\xc3\xa0', 0, 1, 'ordinal not in range(128)') str(err) 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128) unicode(err) u'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128) On Python 2.6 unicode(exception) returns unicode(exception.args): err UnicodeDecodeError('ascii', '\xc3\xa0', 0, 1, 'ordinal not in range(128)') str(err) 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128) unicode(err) u('ascii', '\\xc3\\xa0', 0, 1, 'ordinal not in range(128)') This seems to affect only exceptions with more than 1 arg (e.g. UnicodeErrors and SyntaxErrors). KeyError is also different (the '' are missing with unicode()). Note that when an exception like ValueError() is instantiated with more than 1 arg even str() returns str(exception.args) on both Py2.5 and Py2.6. Probably __str__() checks the number of args before returning a specific message and if it doesn't match it returns str(self.args). __unicode__() instead seems to always return unicode(self.args) on Py2.6. Attached there's a script that prints the repr(), str() and unicode() of some exceptions, run it on Py2.5 and Py2.6 to see the differences. -- components: Interpreter Core files: unicode_exceptions.py messages: 88330 nosy: ezio.melotti severity: normal status: open title: unicode(exception) behaves differently on Py2.6 when len(exception.args) 1 type: behavior versions: Python 2.6 Added file: http://bugs.python.org/file14071/unicode_exceptions.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6108 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com