summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2005-08-24 08:39:46 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2005-08-24 08:39:46 (GMT)
commitea3c6f032bb48d54c04a4605cc3897eaabd6f644 (patch)
treee91439e03e7ef2344b6924c33fbe29843bca6a87
parent674c1882fe59c5d8d8ee33d404dcdaa7d848cbe0 (diff)
downloadcpython-ea3c6f032bb48d54c04a4605cc3897eaabd6f644.zip
cpython-ea3c6f032bb48d54c04a4605cc3897eaabd6f644.tar.gz
cpython-ea3c6f032bb48d54c04a4605cc3897eaabd6f644.tar.bz2
Forward UnicodeDecodeError into SyntaxError for source encoding errors.
-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 1626d6a..6d4df5d 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.4.2a
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 50bb20d..a35bb3f 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1471,18 +1471,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;
}
default: