summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-12-10 23:46:02 (GMT)
committerFred Drake <fdrake@acm.org>2001-12-10 23:46:02 (GMT)
commit2a64f4693ddcd552c4c6e709eaaba7cf829464d8 (patch)
tree0af112c93886d7cfc16c4014df28f0a577f22d27 /Lib/test
parentef8ebd1e74cc8f91d2f0a6e5a8a99c8bd6b125b0 (diff)
downloadcpython-2a64f4693ddcd552c4c6e709eaaba7cf829464d8.zip
cpython-2a64f4693ddcd552c4c6e709eaaba7cf829464d8.tar.gz
cpython-2a64f4693ddcd552c4c6e709eaaba7cf829464d8.tar.bz2
Regression test for SF bug #478534 -- exceptions could "leak" into a weakref
callback.
Diffstat (limited to 'Lib/test')
-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):