mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
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.
This commit is contained in:
parent
2a04623ddd
commit
43440a621e
5 changed files with 18 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue