diff options
author | Walter Dörwald <walter@livinglogic.de> | 2003-03-31 18:07:50 +0000 |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2003-03-31 18:07:50 +0000 |
commit | d57b7af4928b0f0661606d6a0819a2a920e3bb6f (patch) | |
tree | a8b90a661b03741a66700f70842902a0cc19c84c /Objects/stringobject.c | |
parent | bb5fc65c658178a0dbdbd35393a4558e9a37c6ae (diff) | |
download | cpython-d57b7af4928b0f0661606d6a0819a2a920e3bb6f.tar.gz |
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 9598ffb3cf..2613c626e2 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) |