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 amaury.forgeotdarc
Recipients amaury.forgeotdarc, benjamin.peterson, ot
Date 2008-11-20.18:39:31
SpamBayes Score 2.4961848e-06
Marked as misclassified No
Message-id <1227206374.72.0.0450128006451.issue4367@psf.upfronthosting.co.za>
In-reply-to
Content
I think I got the point: to decode strings like "\N{CHARACTER NAME}"
PyUnicode_DecodeUnicodeEscape imports the unicodedata module.
If this fails, PyErr_SetString(PyExc_UnicodeError, "some message")
is called.

The exception will eventually be caught by ast_for_atom (in
Python/ast.c), but the exception there is not normalized: type is
PyExc_UnicodeError when the value is a string. Hence the invalid cast.
The exception cannot be normalized there: UnicodeError.__init__ needs 5
arguments.

I think the error was to call PyErr_SetString in the first place.
The attached patch replaces it with PyErr_SetObject and a full
UnicodeDecodeError object.

This deserves a unit test, but I wonder how to reliably make the import
fail.
History
Date User Action Args
2008-11-20 18:39:34amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, benjamin.peterson, ot
2008-11-20 18:39:34amaury.forgeotdarcsetmessageid: <1227206374.72.0.0450128006451.issue4367@psf.upfronthosting.co.za>
2008-11-20 18:39:32amaury.forgeotdarclinkissue4367 messages
2008-11-20 18:39:32amaury.forgeotdarccreate