diff options
author | Brett Cannon <brett@python.org> | 2011-03-15 17:23:21 -0400 |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2011-03-15 17:23:21 -0400 |
commit | f434ba9e4ef5a68940757ba5e3527dd02fdb53ca (patch) | |
tree | a07c3480561906d1aa0ce04ea6cbd2b732ff3cca /Lib/test/test_dis.py | |
parent | f30645d5521afe5537befd0d9e84a7c539135cdc (diff) | |
parent | 765dcdede824c41011228461e4a5fdaec6fc90d2 (diff) | |
download | cpython-git-f434ba9e4ef5a68940757ba5e3527dd02fdb53ca.tar.gz |
merge
Diffstat (limited to 'Lib/test/test_dis.py')
-rw-r--r-- | Lib/test/test_dis.py | 18 |
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) |