Mercurial > cpython-lru_cache-weakref
diff Python/ast.c @ 49796:0bcafa64eccb 2.6
Merged revisions 67320 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67320 | benjamin.peterson | 2008-11-21 16:27:24 -0600 (Fri, 21 Nov 2008) | 4 lines
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:52:21 +0000 |
| parents | 49f52e285a64 |
| children | 96f38e357194 |
line wrap: on
line diff
--- a/Python/ast.c Fri Nov 21 22:08:14 2008 +0000 +++ b/Python/ast.c Fri Nov 21 22:52:21 2008 +0000 @@ -1287,13 +1287,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"); }
