summaryrefslogtreecommitdiffstats
path: root/Objects/bytearrayobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-07-03 11:42:17 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-07-03 11:42:17 (GMT)
commit6c94d10a193ffdaad9d3b7c2376d9f4de776575f (patch)
tree4910d3b8512256ee95749b0ce863e512b4d55eed /Objects/bytearrayobject.c
parente09132f2c764a9e7df1181b1999d517d949c99e6 (diff)
parentaf65872da2b679e4b1876412aab6a731f82a469f (diff)
downloadcpython-6c94d10a193ffdaad9d3b7c2376d9f4de776575f.zip
cpython-6c94d10a193ffdaad9d3b7c2376d9f4de776575f.tar.gz
cpython-6c94d10a193ffdaad9d3b7c2376d9f4de776575f.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.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 85990e0..50da637 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2303,8 +2303,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);
}