-
- Notifications
You must be signed in to change notification settings - Fork 33.6k
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Consider this code:
from asyncio import run, TaskGroup async def bad_function(): raise ZeroDivisionError async def bad_function2(): raise KeyError async def main(): try: async with TaskGroup() as tg: tg.create_task(bad_function()) tg.create_task(bad_function2()) except* ZeroDivisionError as e: breakpoint() run(main())Run it on Python 3.11 or 3.12:
--Return-- Traceback (most recent call last): File "....py", line 18, in <module> run(main()) File "/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/asyncio/base_events.py", line 650, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File ".....py", line -1, in main File "/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/bdb.py", line 94, in trace_dispatch return self.dispatch_return(frame, arg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/bdb.py", line 153, in dispatch_return self.user_return(frame, arg) File "/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/pdb.py", line 372, in user_return self.interaction(frame, None) File "/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/pdb.py", line 434, in interaction self.print_stack_entry(self.stack[self.curindex]) File "/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/pdb.py", line 1554, in print_stack_entry self.format_stack_entry(frame_lineno, prompt_prefix)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/bdb.py", line 573, in format_stack_entry line = linecache.getline(filename, lineno, frame.f_globals) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jonathan/.pyenv/versions/3.11.0/lib/python3.11/linecache.py", line 31, in getline if 1 <= lineno <= len(lines): TypeError: '<=' not supported between instances of 'int' and 'NoneType'One of the exceptions has to be a ZeroDivisionError for it to happen as far as I can see.
Your environment
- CPython versions tested on: 3.11, 3.12
- Operating system and architecture: Linux, M1, arm64
Linked PRs
- gh-101517: Fix missing linenumber for re-raise in except* #101663
- gh-101517: Attach line number to the RERAISE at the end of a try-except* #101768
- gh-101517: bdb should not lookup linecache with lineno=None #101787
- [3.11] gh-101517: make bdb avoid looking up in linecache with lineno=None (GH-101787) #101793
- [3.10] gh-101517: make bdb avoid looking up in linecache with lineno=None (GH-101787) #101794
- gh-101517: propagate lasti with RERAISE 1 in except* handling to get currect line numbers #103529
- gh-101517: Add regression test for entering pdb in try/except* block #103547
- gh-101517: fix line number propagation in code generated for except* #103550
- [3.11] gh-101517: fix line number propagation in code generated for except* (#103550) #103816
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error