From: Benjamin Peterson Date: Tue, 20 Dec 2011 19:32:50 +0000 (-0600) Subject: merge 3.2 X-Git-Tag: v3.3.0a1~547 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=822c790527eb4601e7303199ad78be4c9eb9bb72;p=thirdparty%2FPython%2Fcpython.git merge 3.2 --- 822c790527eb4601e7303199ad78be4c9eb9bb72 diff --cc Objects/unicodeobject.c index 1eb24dd279b5,c4cfe1bca05c..fd9175d55e83 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@@ -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);