mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-128799: Add frame of except* to traceback when wrapping a naked exception (#128971)
This commit is contained in:
parent
9e52e553f4
commit
c39ae8922b
7 changed files with 44 additions and 6 deletions
|
@ -2937,6 +2937,33 @@ class BaseExceptionReportingTests:
|
|||
report = self.get_report(exc)
|
||||
self.assertEqual(report, expected)
|
||||
|
||||
def test_exception_group_wrapped_naked(self):
|
||||
# See gh-128799
|
||||
|
||||
def exc():
|
||||
try:
|
||||
raise Exception(42)
|
||||
except* Exception as e:
|
||||
raise
|
||||
|
||||
expected = (f' + Exception Group Traceback (most recent call last):\n'
|
||||
f' | File "{__file__}", line {self.callable_line}, in get_exception\n'
|
||||
f' | exception_or_callable()\n'
|
||||
f' | ~~~~~~~~~~~~~~~~~~~~~^^\n'
|
||||
f' | File "{__file__}", line {exc.__code__.co_firstlineno + 3}, in exc\n'
|
||||
f' | except* Exception as e:\n'
|
||||
f' | raise\n'
|
||||
f' | ExceptionGroup: (1 sub-exception)\n'
|
||||
f' +-+---------------- 1 ----------------\n'
|
||||
f' | Traceback (most recent call last):\n'
|
||||
f' | File "{__file__}", line {exc.__code__.co_firstlineno + 2}, in exc\n'
|
||||
f' | raise Exception(42)\n'
|
||||
f' | Exception: 42\n'
|
||||
f' +------------------------------------\n')
|
||||
|
||||
report = self.get_report(exc)
|
||||
self.assertEqual(report, expected)
|
||||
|
||||
def test_KeyboardInterrupt_at_first_line_of_frame(self):
|
||||
# see GH-93249
|
||||
def f():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue