summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dis.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-03-15 20:54:50 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-03-15 20:54:50 (GMT)
commit47afc2af790478dd0cdee628e9c9035766e5d4d4 (patch)
tree95b729e9fa51d57a7264ec3203a44eea35cd87ee /Lib/test/test_dis.py
parent8af4919b37914e73ec547e4216b309705f2f5283 (diff)
downloadcpython-47afc2af790478dd0cdee628e9c9035766e5d4d4.zip
cpython-47afc2af790478dd0cdee628e9c9035766e5d4d4.tar.gz
cpython-47afc2af790478dd0cdee628e9c9035766e5d4d4.tar.bz2
PyErr_Print can leave sys.last_traceback hanging around; kill it
Diffstat (limited to 'Lib/test/test_dis.py')
-rw-r--r--Lib/test/test_dis.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index 7cda0dc..643e2e6 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -265,28 +265,26 @@ class DisTests(unittest.TestCase):
self.do_disassembly_test(method_bytecode, dis_c_instance_method_bytes)
def test_dis_none(self):
+ try:
+ del sys.last_traceback
+ except AttributeError:
+ pass
self.assertRaises(RuntimeError, dis.dis, None)
def test_dis_object(self):
self.assertRaises(TypeError, dis.dis, object())
def test_dis_traceback(self):
- not_defined = object()
- tb = None
- old = getattr(sys, 'last_traceback', not_defined)
-
- def cleanup():
- if old is not not_defined:
- sys.last_traceback = old
- else:
- del sys.last_traceback
+ try:
+ del sys.last_traceback
+ except AttributeError:
+ pass
try:
1/0
except Exception as e:
tb = e.__traceback__
sys.last_traceback = tb
- self.addCleanup(cleanup)
tb_dis = self.get_disassemble_as_string(tb.tb_frame.f_code, tb.tb_lasti)
self.do_disassembly_test(None, tb_dis)