diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-03-18 11:47:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-18 11:47:11 (GMT) |
commit | e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7 (patch) | |
tree | 8363c72cc70b34e06fed5c39d86ec99047613799 /Lib/test | |
parent | 039714d00f147be4d018fa6aeaf174aad7e8fa32 (diff) | |
download | cpython-e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7.zip cpython-e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7.tar.gz cpython-e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7.tar.bz2 |
gh-102778: Add sys.last_exc, deprecate sys.last_type, sys.last_value,sys.last_traceback (#102779)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_dis.py | 10 | ||||
-rw-r--r-- | Lib/test/test_ttk/test_extensions.py | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index b77e3b0..fa1de1c 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -1027,6 +1027,10 @@ class DisTests(DisTestBase): def test_dis_none(self): try: + del sys.last_exc + except AttributeError: + pass + try: del sys.last_traceback except AttributeError: pass @@ -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) @@ -1901,6 +1905,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: pass diff --git a/Lib/test/test_ttk/test_extensions.py b/Lib/test/test_ttk/test_extensions.py index 6135c49..d5e0697 100644 --- a/Lib/test/test_ttk/test_extensions.py +++ b/Lib/test/test_ttk/test_extensions.py @@ -45,7 +45,9 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase): # value which causes the tracing callback to be called and then # it tries calling instance attributes not yet defined. ttk.LabeledScale(self.root, variable=myvar) - if hasattr(sys, 'last_type'): + if hasattr(sys, 'last_exc'): + self.assertNotEqual(type(sys.last_exc), tkinter.TclError) + elif hasattr(sys, 'last_type'): self.assertNotEqual(sys.last_type, tkinter.TclError) def test_initialization(self): |