Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
Consider the following code:
try:raiseValueError()exceptExceptionasexc:breakpoint()
You can't stop in theexcept 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 theexcept block:
(Pdb) import sys(Pdb) sys.exc_info()(None, None, None)(Pdb) p exc*** NameError: name 'exc' is not defined(Pdb)If you put apass in the main function:
try:raiseValueError()exceptExceptionasexc:breakpoint()pass
At least the result is less misleading. Even though it's still not what I want - I want to stop in theexcept block.
> /home/gaogaotiantian/programs/mycpython/example.py(5)<module>()-> passThe "correct" way to do it is to put another line in the block
try:raiseValueError()exceptExceptionasexc:breakpoint()pass
We can stop at thebreakpoint() 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