From: Victor Stinner Date: Mon, 3 Oct 2011 21:27:56 +0000 (+0200) Subject: Fix a compiler warning in PyUnicode_Append() X-Git-Tag: v3.3.0a1~1360 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b80389535581300295758f3a9b50e9628b77ae3c;p=thirdparty%2FPython%2Fcpython.git Fix a compiler warning in PyUnicode_Append() Don't check PyUnicode_CopyCharacters() in release mode. Rename also some variables. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index cb4813f902b0..e045b6bcfa2b 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -9931,9 +9931,11 @@ PyUnicode_Append(PyObject **p_left, PyObject *right) && (_PyUnicode_KIND(right) <= _PyUnicode_KIND(left) || _PyUnicode_WSTR(left) != NULL)) { - Py_ssize_t u_len, v_len, new_len, copied; + Py_ssize_t left_len, right_len, new_len; +#ifdef Py_DEBUG + Py_ssize_t copied; +#endif - /* FIXME: don't make wstr string ready */ if (PyUnicode_READY(left)) goto error; if (PyUnicode_READY(right)) @@ -9942,14 +9944,14 @@ PyUnicode_Append(PyObject **p_left, PyObject *right) /* FIXME: support ascii+latin1, PyASCIIObject => PyCompactUnicodeObject */ if (PyUnicode_MAX_CHAR_VALUE(right) <= PyUnicode_MAX_CHAR_VALUE(left)) { - u_len = PyUnicode_GET_LENGTH(left); - v_len = PyUnicode_GET_LENGTH(right); - if (u_len > PY_SSIZE_T_MAX - v_len) { + left_len = PyUnicode_GET_LENGTH(left); + right_len = PyUnicode_GET_LENGTH(right); + if (left_len > PY_SSIZE_T_MAX - right_len) { PyErr_SetString(PyExc_OverflowError, "strings are too large to concat"); goto error; } - new_len = u_len + v_len; + new_len = left_len + right_len; /* Now we own the last reference to 'left', so we can resize it * in-place. @@ -9964,10 +9966,14 @@ PyUnicode_Append(PyObject **p_left, PyObject *right) goto error; } /* copy 'right' into the newly allocated area of 'left' */ - copied = PyUnicode_CopyCharacters(left, u_len, +#ifdef Py_DEBUG + copied = PyUnicode_CopyCharacters(left, left_len, right, 0, - v_len); + right_len); assert(0 <= copied); +#else + PyUnicode_CopyCharacters(left, left_len, right, 0, right_len); +#endif *p_left = left; return; }