Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: 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. ---------- keywords: +needs review nosy: +amaury.forgeotdarc Added file: http://bugs.python.org/file12078/bad_unicodeerror.patch _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4367> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com