summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-19 18:21:28 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-19 18:21:28 (GMT)
commit00058aa28c8215562995593c57ff9388e2bdb266 (patch)
tree292363642f0cf6cdd72137179ee52ddbf2f530d8 /Objects
parent814661e0d430e1ed8ebc4839fb49a668d02e5a07 (diff)
downloadcpython-00058aa28c8215562995593c57ff9388e2bdb266.zip
cpython-00058aa28c8215562995593c57ff9388e2bdb266.tar.gz
cpython-00058aa28c8215562995593c57ff9388e2bdb266.tar.bz2
Fix a bug in PyUnicode_FromStringAndSize() with signed characters.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 5dc3b41..1399d19 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -438,13 +438,13 @@ PyObject *PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size)
/* 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 @@ PyObject *PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size)
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 */
}