]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Don't calls macros in PyUnicode_WRITE() parameters
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 9 Apr 2013 20:38:52 +0000 (22:38 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 9 Apr 2013 20:38:52 +0000 (22:38 +0200)
PyUnicode_WRITE() expands some parameters twice or more.

Objects/unicodeobject.c

index 52fe3bc55c7dde99b2b25b327da522d1bcc1b601..838d9de9fe997db8694a5b62a65656c6a82aeaea 100644 (file)
@@ -1958,13 +1958,17 @@ _PyUnicode_FromUCS2(const Py_UCS2 *u, Py_ssize_t size)
     assert(size > 0);
     if (size == 1) {
         Py_UCS4 ch = u[0];
+        int kind;
+        void *data;
         if (ch < 256)
             return get_latin1_char((unsigned char)ch);
 
         res = PyUnicode_New(1, ch);
         if (res == NULL)
             return NULL;
-        PyUnicode_WRITE(PyUnicode_KIND(res), PyUnicode_DATA(res), 0, ch);
+        kind = PyUnicode_KIND(res);
+        data = PyUnicode_DATA(res);
+        PyUnicode_WRITE(kind, data, 0, ch);
         assert(_PyUnicode_CheckConsistency(res, 1));
         return res;
     }
@@ -1994,13 +1998,17 @@ _PyUnicode_FromUCS4(const Py_UCS4 *u, Py_ssize_t size)
     assert(size > 0);
     if (size == 1) {
         Py_UCS4 ch = u[0];
+        int kind;
+        void *data;
         if (ch < 256)
             return get_latin1_char((unsigned char)ch);
 
         res = PyUnicode_New(1, ch);
         if (res == NULL)
             return NULL;
-        PyUnicode_WRITE(PyUnicode_KIND(res), PyUnicode_DATA(res), 0, ch);
+        kind = PyUnicode_KIND(res);
+        data = PyUnicode_DATA(res);
+        PyUnicode_WRITE(kind, data, 0, ch);
         assert(_PyUnicode_CheckConsistency(res, 1));
         return res;
     }