mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-102778: Add sys.last_exc, deprecate sys.last_type, sys.last_value,sys.last_traceback (#102779)
This commit is contained in:
parent
039714d00f
commit
e1e9bab006
22 changed files with 103 additions and 36 deletions
|
@ -1026,6 +1026,10 @@ class DisTests(DisTestBase):
|
|||
self.do_disassembly_test(_tryfinallyconst, dis_tryfinallyconst)
|
||||
|
||||
def test_dis_none(self):
|
||||
try:
|
||||
del sys.last_exc
|
||||
except AttributeError:
|
||||
pass
|
||||
try:
|
||||
del sys.last_traceback
|
||||
except AttributeError:
|
||||
|
@ -1043,7 +1047,7 @@ class DisTests(DisTestBase):
|
|||
1/0
|
||||
except Exception as e:
|
||||
tb = e.__traceback__
|
||||
sys.last_traceback = tb
|
||||
sys.last_exc = e
|
||||
|
||||
tb_dis = self.get_disassemble_as_string(tb.tb_frame.f_code, tb.tb_lasti)
|
||||
self.do_disassembly_test(None, tb_dis, True)
|
||||
|
@ -1900,6 +1904,10 @@ class TestFinderMethods(unittest.TestCase):
|
|||
|
||||
class TestDisTraceback(DisTestBase):
|
||||
def setUp(self) -> None:
|
||||
try: # We need to clean up existing tracebacks
|
||||
del sys.last_exc
|
||||
except AttributeError:
|
||||
pass
|
||||
try: # We need to clean up existing tracebacks
|
||||
del sys.last_traceback
|
||||
except AttributeError:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue