mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
SF bug #1242657: list(obj) can swallow KeyboardInterrupt
Fix over-aggressive PyErr_Clear(). The same code fragment appears in various guises in list.extend(), map(), filter(), zip(), and internally in PySequence_Tuple().
This commit is contained in:
parent
b285974c00
commit
a710b331da
4 changed files with 31 additions and 0 deletions
|
@ -514,3 +514,12 @@ class CommonTest(seq_tests.CommonTest):
|
|||
a = self.type2test(range(10))
|
||||
a[::2] = tuple(range(5))
|
||||
self.assertEqual(a, self.type2test([0, 1, 1, 3, 2, 5, 3, 7, 4, 9]))
|
||||
|
||||
def test_constructor_exception_handling(self):
|
||||
# Bug #1242657
|
||||
class F(object):
|
||||
def __iter__(self):
|
||||
yield 23
|
||||
def __len__(self):
|
||||
raise KeyboardInterrupt
|
||||
self.assertRaises(KeyboardInterrupt, list, F())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue