mirror of
https://github.com/python/cpython.git
synced 2025-09-18 14:40:43 +00:00
Regression test for SF bug #478534 -- exceptions could "leak" into a weakref
callback.
This commit is contained in:
parent
ef8ebd1e74
commit
2a64f4693d
1 changed files with 25 additions and 0 deletions
|
@ -227,6 +227,31 @@ class ReferencesTestCase(TestBase):
|
||||||
self.assert_(p + 1.0 == 3.0)
|
self.assert_(p + 1.0 == 3.0)
|
||||||
self.assert_(1.0 + p == 3.0) # this used to SEGV
|
self.assert_(1.0 + p == 3.0) # this used to SEGV
|
||||||
|
|
||||||
|
def test_callbacks_protected(self):
|
||||||
|
"""Callbacks protected from already-set exceptions?"""
|
||||||
|
# Regression test for SF bug #478534.
|
||||||
|
class BogusError(Exception):
|
||||||
|
pass
|
||||||
|
data = {}
|
||||||
|
def remove(k):
|
||||||
|
del data[k]
|
||||||
|
def encapsulate():
|
||||||
|
f = lambda : ()
|
||||||
|
data[weakref.ref(f, remove)] = None
|
||||||
|
raise BogusError
|
||||||
|
try:
|
||||||
|
encapsulate()
|
||||||
|
except BogusError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.fail("exception not properly restored")
|
||||||
|
try:
|
||||||
|
encapsulate()
|
||||||
|
except BogusError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
self.fail("exception not properly restored")
|
||||||
|
|
||||||
|
|
||||||
class Object:
|
class Object:
|
||||||
def __init__(self, arg):
|
def __init__(self, arg):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue