Mercurial > cpython-lru_cache-weakref
diff Python/ast.c @ 49795:b64d053afd84 legacy-trunk
don't segfault when \N escapes are used and unicodedata fails to load
Fixes #4367
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Fri, 21 Nov 2008 22:27:24 +0000 |
| parents | 2e0857b0fc67 |
| children | ffad6c0f252e |
line wrap: on
line diff
--- a/Python/ast.c Fri Nov 21 22:05:48 2008 +0000 +++ b/Python/ast.c Fri Nov 21 22:27:24 2008 +0000 @@ -1294,13 +1294,14 @@ 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 = PyString_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"); }
