[Python-checkins] cpython (3.3): Issue #17223: Fix PyUnicode_FromUnicode() for string of 1 character outside
victor.stinner
python-checkins at python.org
Tue Feb 26 00:20:35 CET 2013
http://hg.python.org/cpython/rev/c354afedb866
changeset: 82386:c354afedb866
branch: 3.3
parent: 82383:af570205b978
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Feb 26 00:15:54 2013 +0100
summary:
Issue #17223: Fix PyUnicode_FromUnicode() for string of 1 character outside
the range U+0000-U+10ffff.
files:
Misc/NEWS | 3 +++
Objects/unicodeobject.c | 14 +++++++-------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@
Core and Builtins
-----------------
+- Issue #17223: Fix PyUnicode_FromUnicode() for string of 1 character outside
+ the range U+0000-U+10ffff.
+
- Issue #17275: Corrected class name in init error messages of the C version of
BufferedWriter and BufferedRandom.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -249,7 +249,7 @@
static PyObject *
-_PyUnicode_FromUCS1(const unsigned char *s, Py_ssize_t size);
+_PyUnicode_FromUCS1(const Py_UCS1 *s, Py_ssize_t size);
static PyObject *
_PyUnicode_FromUCS2(const Py_UCS2 *s, Py_ssize_t size);
static PyObject *
@@ -442,7 +442,7 @@
if (len == 1) {
wchar_t ch = _PyUnicode_WSTR(unicode)[0];
- if (ch < 256) {
+ if ((Py_UCS4)ch < 256) {
PyObject *latin1_char = get_latin1_char((unsigned char)ch);
Py_DECREF(unicode);
return latin1_char;
@@ -1761,7 +1761,7 @@
/* Single character Unicode objects in the Latin-1 range are
shared when using this constructor */
- if (size == 1 && *u < 256)
+ if (size == 1 && (Py_UCS4)*u < 256)
return get_latin1_char((unsigned char)*u);
/* If not empty and not single character, copy the Unicode data
@@ -1869,7 +1869,7 @@
PyObject *unicode;
if (size == 1) {
#ifdef Py_DEBUG
- assert(s[0] < 128);
+ assert((unsigned char)s[0] < 128);
#endif
return get_latin1_char(s[0]);
}
@@ -1911,7 +1911,7 @@
}
static PyObject*
-_PyUnicode_FromUCS1(const unsigned char* u, Py_ssize_t size)
+_PyUnicode_FromUCS1(const Py_UCS1* u, Py_ssize_t size)
{
PyObject *res;
unsigned char max_char;
@@ -2974,8 +2974,8 @@
return NULL;
}
- if (ordinal < 256)
- return get_latin1_char(ordinal);
+ if ((Py_UCS4)ordinal < 256)
+ return get_latin1_char((unsigned char)ordinal);
v = PyUnicode_New(1, ordinal);
if (v == NULL)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list