summaryrefslogtreecommitdiffstats
path: root/Python/ast.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 33b7df6..82f4529 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -2118,17 +2118,19 @@ ast_for_atom(struct compiling *c, const node *n)
errtype = "value error";
if (errtype) {
char buf[128];
+ const char *s = NULL;
PyObject *type, *value, *tback, *errstr;
PyErr_Fetch(&type, &value, &tback);
errstr = PyObject_Str(value);
- if (errstr) {
- char *s = _PyUnicode_AsString(errstr);
+ if (errstr)
+ s = PyUnicode_AsUTF8(errstr);
+ if (s) {
PyOS_snprintf(buf, sizeof(buf), "(%s) %s", errtype, s);
- Py_DECREF(errstr);
} else {
PyErr_Clear();
PyOS_snprintf(buf, sizeof(buf), "(%s) unknown error", errtype);
}
+ Py_XDECREF(errstr);
ast_error(c, n, buf);
Py_DECREF(type);
Py_XDECREF(value);