summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-02-23 12:14:22 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-02-23 12:14:22 (GMT)
commit659eb8445735337650c97fff41118b7a6d8b913e (patch)
tree0fc0e25cdd72cfcb141c46109717a17b332d3583 /Objects
parent02bfdb3f791a007801f2d14ed11b21bd6498ff9c (diff)
downloadcpython-659eb8445735337650c97fff41118b7a6d8b913e.zip
cpython-659eb8445735337650c97fff41118b7a6d8b913e.tar.gz
cpython-659eb8445735337650c97fff41118b7a6d8b913e.tar.bz2
Merged revisions 88481 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r88481 | victor.stinner | 2011-02-21 22:13:44 +0100 (lun., 21 févr. 2011) | 4 lines Fix PyUnicode_FromFormatV("%c") for non-BMP char Issue #10830: Fix PyUnicode_FromFormatV("%c") for non-BMP characters on narrow build. ........
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 4567196..423a533 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -813,8 +813,19 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
switch (*f) {
case 'c':
+ {
+#ifndef Py_UNICODE_WIDE
+ int ordinal = va_arg(count, int);
+ if (ordinal > 0xffff)
+ n += 2;
+ else
+ n++;
+#else
(void)va_arg(count, int);
- /* fall through... */
+ n++;
+#endif
+ break;
+ }
case '%':
n++;
break;
@@ -992,8 +1003,18 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
switch (*f) {
case 'c':
- *s++ = va_arg(vargs, int);
+ {
+ int ordinal = va_arg(vargs, int);
+#ifndef Py_UNICODE_WIDE
+ if (ordinal > 0xffff) {
+ ordinal -= 0x10000;
+ *s++ = 0xD800 | (ordinal >> 10);
+ *s++ = 0xDC00 | (ordinal & 0x3FF);
+ } else
+#endif
+ *s++ = ordinal;
break;
+ }
case 'd':
makefmt(fmt, longflag, longlongflag, size_tflag, zeropad,
width, precision, 'd');