@@ -2919,6 +2919,47 @@ def exc():
29192919 report = self .get_report (exc )
29202920 self .assertEqual (report , expected )
29212921
2922+ def test_except_star_lineno (self ):
2923+ def exc ():
2924+ class Bad (ExceptionGroup ):
2925+ def split (* args ):
2926+ 1 / 0
2927+
2928+ try :
2929+ raise Bad ("" , [ValueError (), TypeError ()])
2930+ except * ValueError :
2931+ 1
2932+ 2
2933+ 3
2934+
2935+ expected = (f' + Exception Group Traceback (most recent call last):\n '
2936+ f' | File "{ __file__ } ", line { exc .__code__ .co_firstlineno + 6 } , in exc\n '
2937+ f' | raise Bad("", [ValueError(), TypeError()])\n '
2938+ f' | test.test_traceback.BaseExceptionReportingTests.test_except_star_lineno.<locals>.exc.<locals>.Bad: (2 sub-exceptions)\n '
2939+ f' +-+---------------- 1 ----------------\n '
2940+ f' | ValueError\n '
2941+ f' +---------------- 2 ----------------\n '
2942+ f' | TypeError\n '
2943+ f' +------------------------------------\n '
2944+ f'\n '
2945+ f'During handling of the above exception, another exception occurred:\n '
2946+ f'\n '
2947+ f'Traceback (most recent call last):\n '
2948+ f' File "{ __file__ } ", line '
2949+ f'{ self .callable_line } , in get_exception\n '
2950+ f' exception_or_callable()\n '
2951+ f' ~~~~~~~~~~~~~~~~~~~~~^^\n '
2952+ f' File "{ __file__ } ", line { exc .__code__ .co_firstlineno + 7 } , in exc\n '
2953+ f' except* ValueError:\n '
2954+ f' \n '
2955+ f' File "{ __file__ } ", line { exc .__code__ .co_firstlineno + 3 } , in split\n '
2956+ f' 1/0\n '
2957+ f' ~^~\n '
2958+ f'ZeroDivisionError: division by zero\n ' )
2959+
2960+ report = self .get_report (exc )
2961+ self .assertEqual (report , expected )
2962+
29222963 def test_KeyboardInterrupt_at_first_line_of_frame (self ):
29232964 # see GH-93249
29242965 def f ():
0 commit comments