diff -r 1dc925ee441a Lib/test/test_heapq.py --- a/Lib/test/test_heapq.py Sat Sep 14 21:16:39 2013 +0200 +++ b/Lib/test/test_heapq.py Sun Sep 15 00:12:42 2013 +0300 @@ -158,6 +158,15 @@ self.assertEqual(sorted(chain(*inputs)), list(self.module.merge(*inputs))) self.assertEqual(list(self.module.merge()), []) + def test_merge_doesnt_suppress_index_error(self): + # Issue 19018: Heapq.merge suppresses IndexError from user generator + def iterable(): + lst = range(10) + for i in xrange(20): + yield lst[i] # IndexError when i > 10 + with self.assertRaises(IndexError): + list(self.module.merge(iterable(), iterable())) + def test_merge_stability(self): class Int(int): pass