Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 566d8a6

Browse files
committed
Jeremy Hylton:
better error message for unicode coercion failure
1 parent 771d067 commit 566d8a6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Objects/unicodeobject.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,10 @@ PyObject *PyUnicode_FromEncodedObject(register PyObject *obj,
406406
/* Overwrite the error message with something more useful in
407407
case of a TypeError. */
408408
if (PyErr_ExceptionMatches(PyExc_TypeError))
409-
PyErr_SetString(PyExc_TypeError,
410-
"coercing to Unicode: need string or buffer");
409+
PyErr_Format(PyExc_TypeError,
410+
"coercing to Unicode: need string or buffer, "
411+
"%.80s found",
412+
obj->ob_type->tp_name);
411413
goto onError;
412414
}
413415

0 commit comments

Comments
 (0)