Skip to content

Commit c63d501

Browse files
Merge branch '3.12' into backport-68c57d6-3.12
2 parents c160ee6 + 96a914a commit c63d501

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Lib/test/test_traceback.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,10 @@ def test_print_exception_exc(self):
329329
self.assertEqual(output.getvalue(), "Exception: projector\n")
330330

331331
def test_print_last(self):
332-
self.assertIsNone(getattr(sys, "last_exc", None))
333-
try:
334-
sys.last_exc = ValueError(42)
332+
with support.swap_attr(sys, 'last_exc', ValueError(42)):
335333
output = StringIO()
336334
traceback.print_last(file=output)
337335
self.assertEqual(output.getvalue(), "ValueError: 42\n")
338-
finally:
339-
sys.last_exc = None
340336

341337
def test_format_exception_exc(self):
342338
e = Exception("projector")

0 commit comments

Comments
 (0)