Simon Cross wrote:
Originally Python exceptions had no __unicode__ method. In Python 2.5
__unicode__ was added. This led to "unicode(Exception)" failing and so
the addition of __unicode__ was reverted [1].

This leaves Python 2.6 in a position where calls to
"unicode(Exception(u'\xe1'))" fail as they are equivalent to
"uncode(str(Exception(u'\xe1'))" which cannot convert the non-ASCII
character to ASCII (or other default encoding) [2].

From here there are 3 options:

 1) Leave things as they are.
 2) Add back __unicode__ and have "unicode(Exception)" fail.
 3) Add a tp_unicode slot to Python objects and have everything work
(at the cost of adding the slot).

4) Fix PyObject_Unicode to not retrieve __unicode__ from new-style instances, and instead only look for the method on their types (similar to the way PyObject_Format looks up the __format__ method).

Cheers,
Nick.

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://www.boredomandlaziness.org
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to