summaryrefslogtreecommitdiffstats
path: root/Python/ast.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-11-21 22:27:24 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-11-21 22:27:24 (GMT)
commitc078f929cb20f3e48fc1636ae8c211bc4f91a483 (patch)
treeccf028e901cb764d739a57cd1c28ba79f2bcd41c /Python/ast.c
parentd42941751c52e4e077e3d94bef6f4a3e545444ee (diff)
downloadcpython-c078f929cb20f3e48fc1636ae8c211bc4f91a483.zip
cpython-c078f929cb20f3e48fc1636ae8c211bc4f91a483.tar.gz
cpython-c078f929cb20f3e48fc1636ae8c211bc4f91a483.tar.bz2
don't segfault when \N escapes are used and unicodedata fails to load
Fixes #4367
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 6eb3aa4..02aa2a7 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -1294,13 +1294,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 = 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");
}