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

Skip to content

Commit 56e4a84

Browse files
committed
Added test to ensure __format__ methods return unicode objects.
1 parent a4b8d1d commit 56e4a84

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

Python/bltinmodule.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,12 @@ builtin_format(PyObject *self, PyObject *args)
312312
/* And call it, binding it to the value */
313313
result = PyObject_CallFunctionObjArgs(meth, value, spec, NULL);
314314

315-
#if 0
316-
/* XXX this is segfaulting, not sure why. find out later! */
317-
if (!PyUnicode_Check(result)) {
315+
if (result && !PyUnicode_Check(result)) {
318316
PyErr_SetString(PyExc_TypeError,
319317
"__format__ method did not return string");
320318
Py_DECREF(result);
321319
return NULL;
322320
}
323-
#endif
324321

325322
return result;
326323
}

0 commit comments

Comments
 (0)