[Python-checkins] cpython (merge 3.5 -> 3.6): Issue #29145: Merge 3.5.
xiang.zhang
python-checkins at python.org
Mon Jan 9 22:05:12 EST 2017
https://hg.python.org/cpython/rev/d966ccda9f17
changeset: 106075:d966ccda9f17
branch: 3.6
parent: 106072:6bf563472ccd
parent: 106074:09b1cdac74de
user: Xiang Zhang <angwerzx at 126.com>
date: Tue Jan 10 10:54:19 2017 +0800
summary:
Issue #29145: Merge 3.5.
files:
Objects/unicodeobject.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -9988,7 +9988,7 @@
use_memcpy = 1;
#endif
for (i = 0; i < seqlen; i++) {
- const Py_ssize_t old_sz = sz;
+ size_t add_sz;
item = items[i];
if (!PyUnicode_Check(item)) {
PyErr_Format(PyExc_TypeError,
@@ -9999,16 +9999,18 @@
}
if (PyUnicode_READY(item) == -1)
goto onError;
- sz += PyUnicode_GET_LENGTH(item);
+ add_sz = PyUnicode_GET_LENGTH(item);
item_maxchar = PyUnicode_MAX_CHAR_VALUE(item);
maxchar = Py_MAX(maxchar, item_maxchar);
- if (i != 0)
- sz += seplen;
- if (sz < old_sz || sz > PY_SSIZE_T_MAX) {
+ if (i != 0) {
+ add_sz += seplen;
+ }
+ if (add_sz > (size_t)(PY_SSIZE_T_MAX - sz)) {
PyErr_SetString(PyExc_OverflowError,
"join() result is too long for a Python string");
goto onError;
}
+ sz += add_sz;
if (use_memcpy && last_obj != NULL) {
if (PyUnicode_KIND(last_obj) != PyUnicode_KIND(item))
use_memcpy = 0;
@@ -10646,7 +10648,7 @@
u = unicode_empty;
goto done;
}
- if (new_size > (PY_SSIZE_T_MAX >> (rkind-1))) {
+ if (new_size > (PY_SSIZE_T_MAX / rkind)) {
PyErr_SetString(PyExc_OverflowError,
"replace string is too long");
goto error;
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list