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.

Author spaceone
Recipients SilentGhost, ezio.melotti, loewis, r.david.murray, spaceone, vstinner
Date 2015-12-17.16:35:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1450370129.89.0.136867127444.issue25880@psf.upfronthosting.co.za>
In-reply-to
Content
I know that UnicodeEncodeError is a subclass of UnicodeError. The problem here is that UnicodeError would also catch UnicodeDecodeError.
This is especially disturbing if you catch errors of a whole function.

If you e.g. use python2.7 you might want to catch only UnicodeEncodeError if you encode something and don't want to catch UnicodeDecodeError.

>>> b'\xff'.encode('utf-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)

(Read that code carefully!!! It's not something which should ever be done but might happen in the world)
Especially if you are writing python2+3 compatible applications.
History
Date User Action Args
2015-12-17 16:35:29spaceonesetrecipients: + spaceone, loewis, vstinner, ezio.melotti, r.david.murray, SilentGhost
2015-12-17 16:35:29spaceonesetmessageid: <1450370129.89.0.136867127444.issue25880@psf.upfronthosting.co.za>
2015-12-17 16:35:29spaceonelinkissue25880 messages
2015-12-17 16:35:29spaceonecreate