mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
apply a fix for #3611 where the current exception context was deleted with a generator causing a segfault
This commit is contained in:
parent
41e36676cd
commit
6e7740c790
2 changed files with 23 additions and 1 deletions
|
@ -564,6 +564,28 @@ class ExceptionTests(unittest.TestCase):
|
|||
pass
|
||||
self.assertEquals(e, (None, None, None))
|
||||
|
||||
def test_3118(self):
|
||||
def gen():
|
||||
try:
|
||||
yield 1
|
||||
finally:
|
||||
pass
|
||||
|
||||
def f():
|
||||
g = gen()
|
||||
next(g)
|
||||
try:
|
||||
try:
|
||||
raise ValueError
|
||||
except:
|
||||
del g
|
||||
raise KeyError
|
||||
except Exception as e:
|
||||
self.assert_(isinstance(e.__context__, ValueError))
|
||||
|
||||
f()
|
||||
|
||||
|
||||
def test_badisinstance(self):
|
||||
# Bug #2542: if issubclass(e, MyException) raises an exception,
|
||||
# it should be ignored
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue