diff options
Diffstat (limited to 'Lib/test/test_b2.py')
-rw-r--r-- | Lib/test/test_b2.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_b2.py b/Lib/test/test_b2.py index 72810cb..459fd6b 100644 --- a/Lib/test/test_b2.py +++ b/Lib/test/test_b2.py @@ -344,7 +344,17 @@ except: if not exc: raise TestFailed, 'zip(a, b) - missing expected TypeError' +# Make sure zip doesn't try to allocate a billion elements for the +# result list when one of its arguments doesn't say how long it is. +# A MemoryError is the most likely failure mode. +class SequenceWithoutALength: + def __getitem__(self, i): + if i == 5: + raise IndexError + else: + return i +vereq(zip(SequenceWithoutALength(), xrange(2**30)), + list(enumerate(range(5)))) # Epilogue -- unlink the temp file - unlink(TESTFN) |