mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
If auto-conversion fails, the Unicode codecs will return NULL.
This is now checked and the error passed on to the caller.
This commit is contained in:
parent
52dc76c81f
commit
891bc65486
1 changed files with 13 additions and 11 deletions
|
@ -268,10 +268,11 @@ PyObject_Repr(v)
|
|||
if (PyUnicode_Check(res)) {
|
||||
PyObject* str;
|
||||
str = PyUnicode_AsEncodedString(res, NULL, NULL);
|
||||
if (str) {
|
||||
Py_DECREF(res);
|
||||
Py_DECREF(res);
|
||||
if (str)
|
||||
res = str;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
if (!PyString_Check(res)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
@ -310,14 +311,15 @@ PyObject_Str(v)
|
|||
}
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
if (PyUnicode_Check(res)) {
|
||||
PyObject* str;
|
||||
str = PyUnicode_AsEncodedString(res, NULL, NULL);
|
||||
if (str) {
|
||||
Py_DECREF(res);
|
||||
res = str;
|
||||
}
|
||||
}
|
||||
if (PyUnicode_Check(res)) {
|
||||
PyObject* str;
|
||||
str = PyUnicode_AsEncodedString(res, NULL, NULL);
|
||||
Py_DECREF(res);
|
||||
if (str)
|
||||
res = str;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
if (!PyString_Check(res)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"__str__ returned non-string (type %.200s)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue