mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #19018: The heapq.merge() function no longer suppresses IndexError
This commit is contained in:
parent
0a32d92bff
commit
46f5ca31d0
4 changed files with 23 additions and 5 deletions
|
@ -158,6 +158,15 @@ class TestHeap:
|
|||
self.assertEqual(sorted(chain(*inputs)), list(self.module.merge(*inputs)))
|
||||
self.assertEqual(list(self.module.merge()), [])
|
||||
|
||||
def test_merge_does_not_suppress_index_error(self):
|
||||
# Issue 19018: Heapq.merge suppresses IndexError from user generator
|
||||
def iterable():
|
||||
s = list(range(10))
|
||||
for i in range(20):
|
||||
yield s[i] # IndexError when i > 10
|
||||
with self.assertRaises(IndexError):
|
||||
list(self.module.merge(iterable(), iterable()))
|
||||
|
||||
def test_merge_stability(self):
|
||||
class Int(int):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue