summaryrefslogtreecommitdiff
path: root/Lib/test/test_dis.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2011-03-15 17:23:21 -0400
committerBrett Cannon <brett@python.org>2011-03-15 17:23:21 -0400
commitf434ba9e4ef5a68940757ba5e3527dd02fdb53ca (patch)
treea07c3480561906d1aa0ce04ea6cbd2b732ff3cca /Lib/test/test_dis.py
parentf30645d5521afe5537befd0d9e84a7c539135cdc (diff)
parent765dcdede824c41011228461e4a5fdaec6fc90d2 (diff)
downloadcpython-git-f434ba9e4ef5a68940757ba5e3527dd02fdb53ca.tar.gz
merge
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 c3b2a4fc72..643e2e66eb 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 != 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)