You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Functions in the traceback module such as format_exc() fail when linecache.getlines() returns a comment or other incorrect source. The following fails with an IndexError: list index out of range exception raised in the format_exc() call.
I know linecache.._register_code() is not public and code that does something like this is buggy, but the traceback module is used to report bugs and shouldn't fail itself.
The fix is probably to check the len(tree.body) in StackSummary._should_show_carets() in traceback.py before accessing tree.body[0]
CPython versions tested on:
3.13
Operating systems tested on:
No response
The text was updated successfully, but these errors were encountered:
Thank you for the report but it's a known issue: #122071 and #122145. So I'm closing it as a duplicate (see also the discussion on #122161 for why we don't want (yet) fixing it like this).
Bug report
Bug description:
Functions in the traceback module such as format_exc() fail when linecache.getlines() returns a comment or other incorrect source. The following fails with an IndexError: list index out of range exception raised in the format_exc() call.
I know linecache.._register_code() is not public and code that does something like this is buggy, but the traceback module is used to report bugs and shouldn't fail itself.
The fix is probably to check the len(tree.body) in StackSummary._should_show_carets() in traceback.py before accessing tree.body[0]
CPython versions tested on:
3.13
Operating systems tested on:
No response
The text was updated successfully, but these errors were encountered: