summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2005-08-24 08:39:24 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2005-08-24 08:39:24 (GMT)
commitd35edda68245a7ab5f74c0f94ab13f6574df6a4e (patch)
tree7bf88606ebb04a0ff76cfe598eef2b14d16a893a
parent56066d2e554b6b92375d3e276f2f02663526c087 (diff)
downloadcpython-d35edda68245a7ab5f74c0f94ab13f6574df6a4e.zip
cpython-d35edda68245a7ab5f74c0f94ab13f6574df6a4e.tar.gz
cpython-d35edda68245a7ab5f74c0f94ab13f6574df6a4e.tar.bz2
Forward UnicodeDecodeError into SyntaxError for source encoding errors.
Will backport to 2.4.
-rw-r--r--Misc/NEWS2
-rw-r--r--Python/pythonrun.c12
2 files changed, 9 insertions, 5 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index a65db9d..f5a2526 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.5 alpha 1?
Core and builtins
-----------------
+- Forward UnicodeDecodeError into SyntaxError for source encoding errors.
+
- SF bug #900092: When tracing (e.g. for hotshot), restore 'return' events for
exceptions that cause a function to exit.
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 9e53564..68948fc 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: