diff options
author | Walter Dörwald <walter@livinglogic.de> | 2003-03-31 18:07:50 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2003-03-31 18:07:50 (GMT) |
commit | 43440a621e022fbeaff24f84dcf4d5458601fedc (patch) | |
tree | 4ffebf718b3a2fef2e38d3b441975b30dde80ea6 /Objects/stringobject.c | |
parent | 2a04623ddd8c15a1d559440a5f4a63d43a3cafd7 (diff) | |
download | cpython-43440a621e022fbeaff24f84dcf4d5458601fedc.zip cpython-43440a621e022fbeaff24f84dcf4d5458601fedc.tar.gz cpython-43440a621e022fbeaff24f84dcf4d5458601fedc.tar.bz2 |
Fix PyString_Format() so that '%c' % u'a' returns u'a'
instead of raising a TypeError. (From SF patch #710127)
Add tests to verify this is fixed.
Add various tests for '%c' % int.
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r-- | Objects/stringobject.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 9598ffb..2613c62 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -3933,6 +3933,13 @@ PyString_Format(PyObject *format, PyObject *args) fill = '0'; break; case 'c': +#ifdef Py_USING_UNICODE + if (PyUnicode_Check(v)) { + fmt = fmt_start; + argidx = argidx_start; + goto unicode; + } +#endif pbuf = formatbuf; len = formatchar(pbuf, sizeof(formatbuf), v); if (len < 0) |