mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
err_input(): don't encode/decode the unicode message
This commit is contained in:
parent
3b2494f38c
commit
b001df0040
1 changed files with 12 additions and 13 deletions
|
@ -1896,7 +1896,7 @@ static void
|
||||||
err_input(perrdetail *err)
|
err_input(perrdetail *err)
|
||||||
{
|
{
|
||||||
PyObject *v, *w, *errtype, *errtext;
|
PyObject *v, *w, *errtype, *errtext;
|
||||||
PyObject* u = NULL;
|
PyObject *msg_obj = NULL;
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
errtype = PyExc_SyntaxError;
|
errtype = PyExc_SyntaxError;
|
||||||
switch (err->error) {
|
switch (err->error) {
|
||||||
|
@ -1952,14 +1952,9 @@ err_input(perrdetail *err)
|
||||||
case E_DECODE: {
|
case E_DECODE: {
|
||||||
PyObject *type, *value, *tb;
|
PyObject *type, *value, *tb;
|
||||||
PyErr_Fetch(&type, &value, &tb);
|
PyErr_Fetch(&type, &value, &tb);
|
||||||
if (value != NULL) {
|
msg = "unknown decode error";
|
||||||
u = PyObject_Str(value);
|
if (value != NULL)
|
||||||
if (u != NULL) {
|
msg_obj = PyObject_Str(value);
|
||||||
msg = _PyUnicode_AsString(u);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (msg == NULL)
|
|
||||||
msg = "unknown decode error";
|
|
||||||
Py_XDECREF(type);
|
Py_XDECREF(type);
|
||||||
Py_XDECREF(value);
|
Py_XDECREF(value);
|
||||||
Py_XDECREF(tb);
|
Py_XDECREF(tb);
|
||||||
|
@ -1988,14 +1983,18 @@ err_input(perrdetail *err)
|
||||||
}
|
}
|
||||||
v = Py_BuildValue("(ziiN)", err->filename,
|
v = Py_BuildValue("(ziiN)", err->filename,
|
||||||
err->lineno, err->offset, errtext);
|
err->lineno, err->offset, errtext);
|
||||||
w = NULL;
|
if (v != NULL) {
|
||||||
if (v != NULL)
|
if (msg_obj)
|
||||||
w = Py_BuildValue("(sO)", msg, v);
|
w = Py_BuildValue("(OO)", msg_obj, v);
|
||||||
Py_XDECREF(u);
|
else
|
||||||
|
w = Py_BuildValue("(sO)", msg, v);
|
||||||
|
} else
|
||||||
|
w = NULL;
|
||||||
Py_XDECREF(v);
|
Py_XDECREF(v);
|
||||||
PyErr_SetObject(errtype, w);
|
PyErr_SetObject(errtype, w);
|
||||||
Py_XDECREF(w);
|
Py_XDECREF(w);
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Py_XDECREF(msg_obj);
|
||||||
if (err->text != NULL) {
|
if (err->text != NULL) {
|
||||||
PyObject_FREE(err->text);
|
PyObject_FREE(err->text);
|
||||||
err->text = NULL;
|
err->text = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue