summaryrefslogtreecommitdiff
path: root/Lib/test/test_bytes.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-07-03 14:42:17 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2016-07-03 14:42:17 +0300
commit6e5626f7c423d97f740ca5b5f17a1496b704a9ab (patch)
treeaa8d439acf2f7bfc83c2809999e34cc49a714a41 /Lib/test/test_bytes.py
parent6341b89ccbfcfb8720a07d133d0eb0d36a0a1bfc (diff)
parent18436ec5ddaac031fea2f7653d2c473e10d1c279 (diff)
downloadcpython-6e5626f7c423d97f740ca5b5f17a1496b704a9ab.tar.gz
Issue #27443: __length_hint__() of bytearray itearator no longer return
negative integer for resized bytearray.
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r--Lib/test/test_bytes.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 9d878caa44..05dc26afaf 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -1328,6 +1328,16 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase):
test_exhausted_iterator = test.list_tests.CommonTest.test_exhausted_iterator
+ def test_iterator_length_hint(self):
+ # Issue 27443: __length_hint__ can return negative integer
+ ba = bytearray(b'ab')
+ it = iter(ba)
+ next(it)
+ ba.clear()
+ # Shouldn't raise an error
+ self.assertEqual(list(it), [])
+
+
class AssortedBytesTest(unittest.TestCase):
#
# Test various combinations of bytes and bytearray