From ea3c6f032bb48d54c04a4605cc3897eaabd6f644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Wed, 24 Aug 2005 08:39:46 +0000 Subject: Forward UnicodeDecodeError into SyntaxError for source encoding errors. --- Python/pythonrun.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 50bb20d15c..a35bb3f3dd 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: -- cgit v1.2.1