This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Standard exceptions are hostile to Unicode
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, mgedmin
Priority: normal Keywords:

Created on 2004-08-20 15:09 by mgedmin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg22152 - (view) Author: Marius Gedminas (mgedmin) * Date: 2004-08-20 15:09
>>> e = ValueError(u"\u2639")
>>> str(e)
  ...
UnicodeEncodeError: 'ascii' codec can't encode
character u'\u2639' in position 0: ordinal not in
range(128)
>>> unicode(e)
  ...
UnicodeEncodeError: 'ascii' codec can't encode
character u'\u2639' in position 0: ordinal not in
range(128)

Please add a __unicode__ method to Exception.  I
suggest the following semantics:

class UnicodeAwareException(Exception):

    def __unicode__(self):
        return u" ".join(map(unicode, self.args))
msg22153 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2006-03-01 04:35
Logged In: YES 
user_id=357491

Rev. 42711 (PEP 352) adds a proper __unicode__ to the
built-in exceptions.
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40794
2004-08-20 15:09:05mgedmincreate