8000 [3.13] gh-130250: fix cleanup in test (impacts refleaks runs) (GH-130… · python/cpython@46237d1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 46237d1

Browse files
[3.13] gh-130250: fix cleanup in test (impacts refleaks runs) (GH-130329) (#130330)
gh-130250: fix cleanup in test (impacts refleaks runs) (GH-130329) (cherry picked from commit c718c6b) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
1 parent d172415 commit 46237d1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Lib/test/test_traceback.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,13 @@ def test_print_exception_exc(self):
518518

519519
def test_print_last(self):
520520
self.assertIsNone(getattr(sys, "last_exc", None))
521-
sys.last_exc = ValueError(42)
522-
output = StringIO()
523-
traceback.print_last(file=output)
524-
self.assertEqual(output.getvalue(), "ValueError: 42\n")
521+
try:
522+
sys.last_exc = ValueError(42)
523+
output = StringIO()
524+
traceback.print_last(file=output)
525+
self.assertEqual(output.getvalue(), "ValueError: 42\n")
526+
finally:
527+
sys.last_exc = None
525528

526529
def test_format_exception_exc(self):
527530
e = Exception("projector")

0 commit comments

Comments
 (0)
0