summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_exceptions.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-03-07 17:10:51 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-03-07 17:10:51 (GMT)
commitae5f2f4a39e6a3f4c45e9dc95bd4e1fe5dfb60f2 (patch)
treedf848682fc6653aeeb109df7fd4547e5efa2817a /Lib/test/test_exceptions.py
parent0e4c22c922c67297e5664ff9685b143fff1fddf5 (diff)
downloadcpython-ae5f2f4a39e6a3f4c45e9dc95bd4e1fe5dfb60f2.zip
cpython-ae5f2f4a39e6a3f4c45e9dc95bd4e1fe5dfb60f2.tar.gz
cpython-ae5f2f4a39e6a3f4c45e9dc95bd4e1fe5dfb60f2.tar.bz2
prevent generator finalization from invalidating sys.exc_info() #7173
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r--Lib/test/test_exceptions.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 2838d47..5372b2b 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -6,7 +6,8 @@ import unittest
import pickle
import weakref
-from test.support import TESTFN, unlink, run_unittest, captured_output
+from test.support import (TESTFN, unlink, run_unittest, captured_output,
+ gc_collect)
# XXX This is not really enough, each *operation* should be tested!
@@ -554,6 +555,20 @@ class ExceptionTests(unittest.TestCase):
del g
self.assertEquals(sys.exc_info()[0], TypeError)
+ def test_generator_finalizing_and_exc_info(self):
+ # See #7173
+ def simple_gen():
+ yield 1
+ def run_gen():
+ gen = simple_gen()
+ try:
+ raise RuntimeError
+ except RuntimeError:
+ return next(gen)
+ run_gen()
+ gc_collect()
+ self.assertEqual(sys.exc_info(), (None, None, None))
+
def test_3114(self):
# Bug #3114: in its destructor, MyObject retrieves a pointer to
# obsolete and/or deallocated objects.