]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Added test to ensure __format__ methods return unicode objects.
authorEric Smith <eric@trueblade.com>
Mon, 27 Aug 2007 15:31:40 +0000 (15:31 +0000)
committerEric Smith <eric@trueblade.com>
Mon, 27 Aug 2007 15:31:40 +0000 (15:31 +0000)
Python/bltinmodule.c

index 284910d9eae777cb20047520bc899fb8b0d4bc7b..b0b85ba0d9467e9894d1daeb432d8634eeb00014 100644 (file)
@@ -312,15 +312,12 @@ builtin_format(PyObject *self, PyObject *args)
         /* And call it, binding it to the value */
         result = PyObject_CallFunctionObjArgs(meth, value, spec, NULL);
 
-#if 0
-        /* XXX this is segfaulting, not sure why.  find out later! */
-       if (!PyUnicode_Check(result)) {
+       if (result && !PyUnicode_Check(result)) {
                 PyErr_SetString(PyExc_TypeError,
                                 "__format__ method did not return string");
                 Py_DECREF(result);
                 return NULL;
         }
-#endif
 
         return result;
 }