diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-08 00:07:07 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-08 00:07:07 (GMT) |
commit | b001df0040c8e4472292522708b0ed6ea2501b6f (patch) | |
tree | 6ce136431cf5259e44f9b380912e8dee96a00c6a /Python/pythonrun.c | |
parent | 3b2494f38c17ad9d673a1b8cac8d4143ba06e3df (diff) | |
download | cpython-b001df0040c8e4472292522708b0ed6ea2501b6f.zip cpython-b001df0040c8e4472292522708b0ed6ea2501b6f.tar.gz cpython-b001df0040c8e4472292522708b0ed6ea2501b6f.tar.bz2 |
err_input(): don't encode/decode the unicode message
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index cc617be..225d178 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1896,7 +1896,7 @@ static void err_input(perrdetail *err) { PyObject *v, *w, *errtype, *errtext; - PyObject* u = NULL; + PyObject *msg_obj = NULL; char *msg = NULL; errtype = PyExc_SyntaxError; switch (err->error) { @@ -1952,14 +1952,9 @@ err_input(perrdetail *err) case E_DECODE: { PyObject *type, *value, *tb; PyErr_Fetch(&type, &value, &tb); - if (value != NULL) { - u = PyObject_Str(value); - if (u != NULL) { - msg = _PyUnicode_AsString(u); - } - } - if (msg == NULL) - msg = "unknown decode error"; + msg = "unknown decode error"; + if (value != NULL) + msg_obj = PyObject_Str(value); Py_XDECREF(type); Py_XDECREF(value); Py_XDECREF(tb); @@ -1988,14 +1983,18 @@ err_input(perrdetail *err) } v = Py_BuildValue("(ziiN)", err->filename, err->lineno, err->offset, errtext); - w = NULL; - if (v != NULL) - w = Py_BuildValue("(sO)", msg, v); - Py_XDECREF(u); + if (v != NULL) { + if (msg_obj) + w = Py_BuildValue("(OO)", msg_obj, v); + else + w = Py_BuildValue("(sO)", msg, v); + } else + w = NULL; Py_XDECREF(v); PyErr_SetObject(errtype, w); Py_XDECREF(w); cleanup: + Py_XDECREF(msg_obj); if (err->text != NULL) { PyObject_FREE(err->text); err->text = NULL; |