https://github.com/python/cpython/commit/c718c6be0f82af5eb0e57615ce323242155ff014
commit: c718c6be0f82af5eb0e57615ce323242155ff014
branch: main
author: Irit Katriel <[email protected]>
committer: iritkatriel <[email protected]>
date: 2025-02-20T01:37:30Z
summary:
gh-130250: fix cleanup in test (impacts refleaks runs) (#130329)
files:
M Lib/test/test_traceback.py
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 58f28902686a17..266a1ec04908fc 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -512,10 +512,13 @@ def test_print_exception_exc(self):
def test_print_last(self):
self.assertIsNone(getattr(sys, "last_exc", None))
- sys.last_exc = ValueError(42)
- output = StringIO()
- traceback.print_last(file=output)
- self.assertEqual(output.getvalue(), "ValueError: 42\n")
+ try:
+ sys.last_exc = ValueError(42)
+ output = StringIO()
+ traceback.print_last(file=output)
+ self.assertEqual(output.getvalue(), "ValueError: 42\n")
+ finally:
+ sys.last_exc = None
def test_format_exception_exc(self):
e = Exception("projector")
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]