]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
merge 3.2
authorBenjamin Peterson <benjamin@python.org>
Tue, 20 Dec 2011 19:32:50 +0000 (13:32 -0600)
committerBenjamin Peterson <benjamin@python.org>
Tue, 20 Dec 2011 19:32:50 +0000 (13:32 -0600)
1  2 
Objects/unicodeobject.c

index 1eb24dd279b5ecba38a5f0b784c4b9841c09ece8,c4cfe1bca05cf7a4da8838e8cea812ae77db7067..fd9175d55e83a4334aaea49f8d2420cccfa5bf51
@@@ -12585,15 -8886,15 +12585,19 @@@ unicode_maketrans(PyObject *null, PyObj
              goto err;
          }
          /* create entries for translating chars in x to those in y */
 -        for (i = 0; i < PyUnicode_GET_SIZE(x); i++) {
 -            key = PyLong_FromLong(PyUnicode_AS_UNICODE(x)[i]);
 +        x_kind = PyUnicode_KIND(x);
 +        y_kind = PyUnicode_KIND(y);
 +        x_data = PyUnicode_DATA(x);
 +        y_data = PyUnicode_DATA(y);
 +        for (i = 0; i < PyUnicode_GET_LENGTH(x); i++) {
 +            key = PyLong_FromLong(PyUnicode_READ(x_kind, x_data, i));
+             if (!key)
+                 goto err;
 -            value = PyLong_FromLong(PyUnicode_AS_UNICODE(y)[i]);
 +            value = PyLong_FromLong(PyUnicode_READ(y_kind, y_data, i));
-             if (!key || !value)
+             if (!value) {
+                 Py_DECREF(key);
                  goto err;
+             }
              res = PyDict_SetItem(new, key, value);
              Py_DECREF(key);
              Py_DECREF(value);