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
#116660 closed gh-90095 to properly handle commands issued through -c or .pdbrc. The pdb documentation also speaks of convenience variables which is a debugging global variable. I was expecting to be able to define a variable starting with $ as defined in the documentation below, and make manipulations to that variable through commands in a .pdbrc, but doing the following $_capture_list = [] in .pdbrc issues a syntax error
To set a temporary global variable, use a convenience variable. A convenience variable is a variable whose name starts with $. For example, $foo = 1 sets a global variable $foo which you can use in the debugger session. The convenience variables are cleared when the program resumes execution so it’s less likely to interfere with your program compared to using normal variables like foo = 1.
I may be misunderstanding the paragraph. Perhaps the convenience variable is restricted to the scope of the command and should not be persistent throughout the entire debugging session.
First of all, you listed that you were using Python 3.11, is that the case? Convenience variable is a feature added in Python 3.12 so it won't work with 3.11.
First of all, you listed that you were using Python 3.11, is that the case? Convenience variable is a feature added in Python 3.12 so it won't work with 3.11.
Defining a convenience variable through .pdbrc does indeed work correctly when using 3.12 with your backport. Although from the paragraph I believe I was misunderstanding how it persists between breakpoints (it doesn't appear to).
With that being said I do find it unclear that convenience variables were added in 3.12 or specific convenience variables ($_frame, etc.) were added in 3.12, or really what of the previous 6 paragraphs was added 3.12.
Activity
Delengowski commentedon May 26, 2024
I may be misunderstanding the paragraph. Perhaps the convenience variable is restricted to the scope of the command and should not be persistent throughout the entire debugging session.
Example program
In the same directory
.pdbrcDisplays
*** SyntaxError: invalid syntaxInstead I attempt
Then invoke with
python -m pdb example.pyand manually typeWhich does not work either, I'm presuming because there is no breakpoint to associate that command with.
What does work is
gaogaotiantian commentedon May 26, 2024
First of all, you listed that you were using Python 3.11, is that the case? Convenience variable is a feature added in Python 3.12 so it won't work with 3.11.
Delengowski commentedon May 26, 2024
Ah, let me try 3.12 with your backport
Delengowski commentedon May 26, 2024
Defining a convenience variable through
.pdbrcdoes indeed work correctly when using 3.12 with your backport. Although from the paragraph I believe I was misunderstanding how it persists between breakpoints (it doesn't appear to).With that being said I do find it unclear that convenience variables were added in 3.12 or specific convenience variables (
$_frame, etc.) were added in 3.12, or really what of the previous 6 paragraphs was added 3.12.gaogaotiantian commentedon May 26, 2024
I agree that the added version is not super clear and I can try to improve it. However, about the persistence:
Your program resumes execution between breakpoints so the convenience variables will be cleared. I think this behavior is well-described.
Delengowski commentedon May 26, 2024
Yes I misunderstood the behavior of the convenience variables. As such I will close this.
gh-119580: Improve version added section for convenience variable (#1…
pythongh-119580: Improve version added section for convenience variab…
pythongh-119580: Improve version added section for convenience variab…
[3.12] gh-119580: Improve version added section for convenience varia…
[3.13] gh-119580: Improve version added section for convenience varia…
pythongh-119580: Improve version added section for convenience variab…