Author: guido.van.rossum
Date: Thu Jul 19 20:21:28 2007
New Revision: 56460

Modified:
   python/branches/py3k-struni/Objects/unicodeobject.c
Log:
Fix a bug in PyUnicode_FromStringAndSize() with signed characters.


Modified: python/branches/py3k-struni/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k-struni/Objects/unicodeobject.c (original)
+++ python/branches/py3k-struni/Objects/unicodeobject.c Thu Jul 19 20:21:28 2007
@@ -438,13 +438,13 @@
 
        /* Single characters are shared when using this constructor */
        if (size == 1) {
-           unicode = unicode_latin1[(int)*u];
+           unicode = unicode_latin1[Py_CHARMASK(*u)];
            if (!unicode) {
                unicode = _PyUnicode_New(1);
                if (!unicode)
                    return NULL;
-               unicode->str[0] = *u;
-               unicode_latin1[(int)*u] = unicode;
+               unicode->str[0] = Py_CHARMASK(*u);
+               unicode_latin1[Py_CHARMASK(*u)] = unicode;
            }
            Py_INCREF(unicode);
            return (PyObject *)unicode;
@@ -459,7 +459,7 @@
     if (u != NULL) {
         Py_UNICODE *p = unicode->str;
         while (size--)
-            *p++ = *u++;
+            *p++ = Py_CHARMASK(*u++);
         /* Don't need to write trailing 0 because
            that's already done by _PyUnicode_New */
     }
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to