diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-07-03 11:41:36 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-07-03 11:41:36 (GMT) |
commit | af65872da2b679e4b1876412aab6a731f82a469f (patch) | |
tree | 24ae9a673e5203c75b0ac4fc5dd4bfb7acb8fb01 /Objects/bytearrayobject.c | |
parent | 8faca61fec8ef004feb534dee3da052f3bed82ce (diff) | |
download | cpython-af65872da2b679e4b1876412aab6a731f82a469f.zip cpython-af65872da2b679e4b1876412aab6a731f82a469f.tar.gz cpython-af65872da2b679e4b1876412aab6a731f82a469f.tar.bz2 |
Issue #27443: __length_hint__() of bytearray itearator no longer return
negative integer for resized bytearray.
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r-- | Objects/bytearrayobject.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 277be59..388e990 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -3192,8 +3192,12 @@ static PyObject * bytearrayiter_length_hint(bytesiterobject *it) { Py_ssize_t len = 0; - if (it->it_seq) + if (it->it_seq) { len = PyByteArray_GET_SIZE(it->it_seq) - it->it_index; + if (len < 0) { + len = 0; + } + } return PyLong_FromSsize_t(len); } |