Commit 891bc654 authored by Marc-André Lemburg's avatar Marc-André Lemburg

If auto-conversion fails, the Unicode codecs will return NULL.

This is now checked and the error passed on to the caller.
parent 52dc76c8
...@@ -268,10 +268,11 @@ PyObject_Repr(v) ...@@ -268,10 +268,11 @@ PyObject_Repr(v)
if (PyUnicode_Check(res)) { if (PyUnicode_Check(res)) {
PyObject* str; PyObject* str;
str = PyUnicode_AsEncodedString(res, NULL, NULL); str = PyUnicode_AsEncodedString(res, NULL, NULL);
if (str) {
Py_DECREF(res); Py_DECREF(res);
if (str)
res = str; res = str;
} else
return NULL;
} }
if (!PyString_Check(res)) { if (!PyString_Check(res)) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
...@@ -313,10 +314,11 @@ PyObject_Str(v) ...@@ -313,10 +314,11 @@ PyObject_Str(v)
if (PyUnicode_Check(res)) { if (PyUnicode_Check(res)) {
PyObject* str; PyObject* str;
str = PyUnicode_AsEncodedString(res, NULL, NULL); str = PyUnicode_AsEncodedString(res, NULL, NULL);
if (str) {
Py_DECREF(res); Py_DECREF(res);
if (str)
res = str; res = str;
} else
return NULL;
} }
if (!PyString_Check(res)) { if (!PyString_Check(res)) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment