merge
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py
index b48ca68..b5a2fd8 100644
--- a/Lib/test/test_heapq.py
+++ b/Lib/test/test_heapq.py
@@ -158,6 +158,15 @@
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
diff --git a/Misc/ACKS b/Misc/ACKS
index 17d2e75..cb823d1 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -394,6 +394,7 @@
Frederik Fix
Matt Fleming
Hernán Martínez Foffani
+Artem Fokin
Arnaud Fontaine
Michael Foord
Amaury Forgeot d'Arc
diff --git a/Misc/NEWS b/Misc/NEWS
index face3a9..8845e3d 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,9 @@
- Issue #17324: Fix http.server's request handling case on trailing '/'. Patch
contributed by Vajrasky Kok.
+- Issue #19018: The heapq.merge() function no longer suppresses IndexError
+ in the underlying iterables.
+
- Issue #18784: The uuid module no more attempts to load libc via ctypes.CDLL,
if all necessary functions are already found in libuuid.
Patch by Evgeny Sologubov.