Bug report
Bug description:
Consider the following code:
try:
raise ValueError()
except Exception as exc:
breakpoint()
You can't stop in the except block, you'll get:
--Return--
> /home/gaogaotiantian/programs/mycpython/example.py(4)<module>()->None
-> breakpoint()
(Pdb)
which is pretty misleading because you can't access anything in the except block:
(Pdb) import sys
(Pdb) sys.exc_info()
(None, None, None)
(Pdb) p exc
*** NameError: name 'exc' is not defined
(Pdb)
If you put a pass in the main function:
try:
raise ValueError()
except Exception as exc:
breakpoint()
pass
At least the result is less misleading. Even though it's still not what I want - I want to stop in the except block.
> /home/gaogaotiantian/programs/mycpython/example.py(5)<module>()
-> pass
The "correct" way to do it is to put another line in the block
try:
raise ValueError()
except Exception as exc:
breakpoint()
pass
We can stop at the breakpoint() actually, but that's a breaking behavior, I don't think we want that. So maybe we should at least document this in pdb so users get less confused?
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
Consider the following code:
You can't stop in the
exceptblock, you'll get:which is pretty misleading because you can't access anything in the
exceptblock:If you put a
passin the main function:At least the result is less misleading. Even though it's still not what I want - I want to stop in the
exceptblock.The "correct" way to do it is to put another line in the block
We can stop at the
breakpoint()actually, but that's a breaking behavior, I don't think we want that. So maybe we should at least document this in pdb so users get less confused?CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
breakpoint()enter the debugger immediately #118579