diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-03 23:27:56 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-03 23:27:56 +0200 |
commit | b80389535581300295758f3a9b50e9628b77ae3c (patch) | |
tree | 4e894961b1ebd6e3168a2d9f1e4d88647ae86c52 | |
parent | 8cfcbed4e3858e84426e606f18f87b5f3b4572fd (diff) | |
download | cpython-git-b80389535581300295758f3a9b50e9628b77ae3c.tar.gz |
Fix a compiler warning in PyUnicode_Append()
Don't check PyUnicode_CopyCharacters() in release mode. Rename also some
variables.
-rw-r--r-- | Objects/unicodeobject.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index cb4813f902..e045b6bcfa 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; } |