Skip to content

Commit 65cf6e7

Browse files
committed
add test
1 parent 1443bf8 commit 65cf6e7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Lib/test/test_traceback.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2919,6 +2919,32 @@ def exc():
29192919
report = self.get_report(exc)
29202920
self.assertEqual(report, expected)
29212921

2922+
def test_exception_group_wrapped_naked(self):
2923+
# See gh-128799
2924+
2925+
def exc():
2926+
try:
2927+
raise Exception(42)
2928+
except* Exception as e:
2929+
raise
2930+
2931+
expected = (f' + Exception Group Traceback (most recent call last):\n'
2932+
f' | File "{__file__}", line {self.callable_line}, in get_exception\n'
2933+
f' | exception_or_callable()\n'
2934+
f' | ~~~~~~~~~~~~~~~~~~~~~^^\n'
2935+
f' | File "{__file__}", line {exc.__code__.co_firstlineno + 3}, in exc\n'
2936+
f' | except* Exception as e:\n'
2937+
f' | ExceptionGroup: (1 sub-exception)\n'
2938+
f' +-+---------------- 1 ----------------\n'
2939+
f' | Traceback (most recent call last):\n'
2940+
f' | File "{__file__}", line {exc.__code__.co_firstlineno + 2}, in exc\n'
2941+
f' | raise Exception(42)\n'
2942+
f' | Exception: 42\n'
2943+
f' +------------------------------------\n')
2944+
2945+
report = self.get_report(exc)
2946+
self.assertEqual(report, expected)
2947+
29222948
def test_KeyboardInterrupt_at_first_line_of_frame(self):
29232949
# see GH-93249
29242950
def f():

0 commit comments

Comments
 (0)