[Python-checkins] CVS: python/dist/src/Lib/test test_weakref.py,1.15,1.16
Fred L. Drake
fdrake@users.sourceforge.net
Mon, 10 Dec 2001 15:46:04 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv26179/Lib/test
Modified Files:
test_weakref.py
Log Message:
Regression test for SF bug #478534 -- exceptions could "leak" into a weakref
callback.
Index: test_weakref.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** test_weakref.py 2001/11/06 16:38:34 1.15
--- test_weakref.py 2001/12/10 23:46:02 1.16
***************
*** 228,231 ****
--- 228,256 ----
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: