-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
breakpoint
does not enter pdb until the "next event" happens
#111744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes! This behavior remains incredibly surprising to me, and is something I have to re-learn every couple of months. I think I even remember it tripping up @markshannon on at least one occasion, too.
Honestly, I find the current behavior annoying and unintuitive enough that a change would be welcome (others may disagree, though). I doubt that there are many "load-bearing" When I put a What mechanism are you imagining using to stop at the breakpoint line? A one-off |
I believe we need to make I believe that can be done (without a working prototype yet), but we need to change basically ALL the pdb tests (the doctest ones) because the stop line will change. I agree this is undoubtedly the expected behavior - the question is whether it's better enough to make the change. |
By pure coincidence, I stumbled onto this issue today in pytest-dev/pytest#11512 (comment).
My instinct is yes. This surprising behavior has bit me before and added confusion to an already challenging scenario. I'd prefer to meet the user's expectation (that PDB should break in the block where the breakpoint is written) rather than document the deficiency (that PDB breaks before the next statement or return). On the other hand, when I think about breakpoints defined visually (such as in an IDE) or programmatically (such as through pdb's I still lean toward causing the break to occur on the line with the breakpoint call. |
It's true that the user can only set breakpoints on existing statements, whether through the debugger command line interface or the IDE, but Personally, I don't think how a breakpoint behaves without the statement should impact how it behaves with the explicit statement. However, I do have backward compatibility concerns and we should probably get a broader audience for the feature. |
Bug report
Bug description:
Consider the following code:
You can't stop in the
except
block, you'll get:which is pretty misleading because you can't access anything in the
except
block:If you put a
pass
in 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
except
block.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 #118579The text was updated successfully, but these errors were encountered: