From f50a4e9bc940e701feb142c35a267c90fc1fff8e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 9 Apr 2013 22:38:52 +0200 Subject: [PATCH] Don't calls macros in PyUnicode_WRITE() parameters PyUnicode_WRITE() expands some parameters twice or more. --- Objects/unicodeobject.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 52fe3bc55c..838d9de9fe 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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; } -- 2.40.0