diff options
author | Eric Smith <eric@trueblade.com> | 2008-02-18 18:07:47 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2008-02-18 18:07:47 (GMT) |
commit | 8a0217cd8671af754d8d677d59d8a28615b28530 (patch) | |
tree | 9c9777f6ba882d406353f3e5bcec0fb6cfd5e38c /Objects/stringlib/string_format.h | |
parent | 537a6258adab1b51cb1de3d0a18c7034a610cb90 (diff) | |
download | cpython-8a0217cd8671af754d8d677d59d8a28615b28530.zip cpython-8a0217cd8671af754d8d677d59d8a28615b28530.tar.gz cpython-8a0217cd8671af754d8d677d59d8a28615b28530.tar.bz2 |
Port 60893 to py3k, without unicode test.
Diffstat (limited to 'Objects/stringlib/string_format.h')
-rw-r--r-- | Objects/stringlib/string_format.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Objects/stringlib/string_format.h b/Objects/stringlib/string_format.h index 70f8f13..e776242 100644 --- a/Objects/stringlib/string_format.h +++ b/Objects/stringlib/string_format.h @@ -493,6 +493,22 @@ render_field(PyObject *fieldobj, SubString *format_spec, OutputString *output) 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: |