summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2003-03-31 18:07:50 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2003-03-31 18:07:50 (GMT)
commit43440a621e022fbeaff24f84dcf4d5458601fedc (patch)
tree4ffebf718b3a2fef2e38d3b441975b30dde80ea6 /Objects/stringobject.c
parent2a04623ddd8c15a1d559440a5f4a63d43a3cafd7 (diff)
downloadcpython-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.c7
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)