summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2005-08-24 08:39:24 +0000
committerMartin v. Löwis <martin@v.loewis.de>2005-08-24 08:39:24 +0000
commitdeeadd21abd2ca9e7305cfb964624610e00d135d (patch)
tree0f92e0a5ecae66115969b79fcaab448d6ce8eae4 /Python/pythonrun.c
parenta6fc4606bbc14eef07e24977682b8784b9ec0418 (diff)
downloadcpython-deeadd21abd2ca9e7305cfb964624610e00d135d.tar.gz
Forward UnicodeDecodeError into SyntaxError for source encoding errors.
Will backport to 2.4.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 9e53564ad8..68948fc34c 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1474,18 +1474,20 @@ err_input(perrdetail *err)
errtype = PyExc_IndentationError;
msg = "too many levels of indentation";
break;
- case E_DECODE: { /* XXX */
- PyThreadState* tstate = PyThreadState_GET();
- PyObject* value = tstate->curexc_value;
+ case E_DECODE: {
+ PyObject *type, *value, *tb;
+ PyErr_Fetch(&type, &value, &tb);
if (value != NULL) {
- u = PyObject_Repr(value);
+ u = PyObject_Str(value);
if (u != NULL) {
msg = PyString_AsString(u);
- break;
}
}
if (msg == NULL)
msg = "unknown decode error";
+ Py_DECREF(type);
+ Py_DECREF(value);
+ Py_DECREF(tb);
break;
}
case E_LINECONT: