diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ast.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/ast.c b/Python/ast.c index 1cf100e..df94850 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -1321,13 +1321,14 @@ ast_for_atom(struct compiling *c, const node *n) if (PyErr_ExceptionMatches(PyExc_UnicodeError)) { PyObject *type, *value, *tback, *errstr; PyErr_Fetch(&type, &value, &tback); - errstr = ((PyUnicodeErrorObject *)value)->reason; + errstr = PyObject_Str(value); if (errstr) { char *s = ""; char buf[128]; s = _PyUnicode_AsString(errstr); PyOS_snprintf(buf, sizeof(buf), "(unicode error) %s", s); ast_error(n, buf); + Py_DECREF(errstr); } else { ast_error(n, "(unicode error) unknown error"); } |