diff Objects/stringobject.c @ 28478:8802de0da533 legacy-trunk

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.
author Walter Dörwald <walter@livinglogic.de>
date Mon, 31 Mar 2003 18:07:50 +0000
parents 17bfd5dbc0f1
children aff080f2efb4
line wrap: on
line diff
--- a/Objects/stringobject.c	Mon Mar 31 16:23:09 2003 +0000
+++ b/Objects/stringobject.c	Mon Mar 31 18:07:50 2003 +0000
@@ -3933,6 +3933,13 @@
 					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)