summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_weakref.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 1623039..7f4870e 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -227,6 +227,31 @@ class ReferencesTestCase(TestBase):
self.assert_(p + 1.0 == 3.0)
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:
def __init__(self, arg):