mirror of
https://github.com/python/cpython.git
synced 2025-07-30 22:54:16 +00:00
[3.13] gh-130250: fix regression in traceback.print_last (GH-130318) (#130325)
gh-130250: fix regression in traceback.print_last (GH-130318)
(cherry picked from commit 6c982aeb54
)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
parent
6c92424b94
commit
d172415a4e
4 changed files with 16 additions and 8 deletions
|
@ -516,6 +516,13 @@ class TracebackCases(unittest.TestCase):
|
|||
traceback.print_exception(Exception("projector"), file=output)
|
||||
self.assertEqual(output.getvalue(), "Exception: projector\n")
|
||||
|
||||
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")
|
||||
|
||||
def test_format_exception_exc(self):
|
||||
e = Exception("projector")
|
||||
output = traceback.format_exception(e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue