[Python-3000-checkins] r60894 - python/branches/py3k/Objects/stringlib/string_format.h
eric.smith
python-3000-checkins at python.org
Mon Feb 18 19:07:48 CET 2008
Author: eric.smith
Date: Mon Feb 18 19:07:47 2008
New Revision: 60894
Modified:
python/branches/py3k/Objects/stringlib/string_format.h
Log:
Port 60893 to py3k, without unicode test.
Modified: python/branches/py3k/Objects/stringlib/string_format.h
==============================================================================
--- python/branches/py3k/Objects/stringlib/string_format.h (original)
+++ python/branches/py3k/Objects/stringlib/string_format.h Mon Feb 18 19:07:47 2008
@@ -493,6 +493,22 @@
if (result == NULL)
goto done;
+#if PY_VERSION_HEX >= 0x03000000
+ assert(PyString_Check(result));
+#else
+ assert(PyString_Check(result) || PyUnicode_Check(result));
+
+ /* Convert result to our type. We could be str, and result could
+ be unicode */
+ {
+ PyObject *tmp = STRINGLIB_TOSTR(result);
+ if (tmp == NULL)
+ goto done;
+ Py_DECREF(result);
+ result = tmp;
+ }
+#endif
+
ok = output_data(output,
STRINGLIB_STR(result), STRINGLIB_LEN(result));
done:
More information about the Python-3000-checkins
mailing list