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
Using specific values as variable names in breakpoints leads to incorrect behaviour.
This seems to be because certain chars are used as aliases in pdb, i.e c is continue, p is print etc.
It is triggered when the following char is non-alpha-numeric, afaict.
MRE:
Python3.9.5 (default, Sep142021, 12:04:19)
[GCC9.3.0] onlinuxType"help", "copyright", "credits"or"license"formoreinformation.
>>>breakpoint()
--Return--><stdin>(1)<module>()->None
(Pdb) c=None>>>cTraceback (mostrecentcalllast):
File"<stdin>", line1, in<module>NameError: name'c'isnotdefined>>># I expect to still be in a breakpoint here, and for `c` to be `None`, but pdb has 'continued' execution instead.
The same is true for other aliases, like q and p, which raise errors relating to their respective functions. (I have not tried all aliases).
CPython versions tested on:
3.9
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered:
I can reproduce your results on Python 3.12, but the output is pretty different on main (likely because of some changes @gaogaotiantian has been making to improve pdb):
Running Debug|x64 interpreter...
Python 3.13.0a1+ (heads/main:232465204e, Oct 17 2023, 15:23:17) [MSC v.1932 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> breakpoint()
--Return--
> <python-input-0>(1)<module>()->None
-> breakpoint()
(Pdb) c = None
*** Invalid argument: = None
Usage: c(ont(inue))
(Pdb)
Right, the fix just missed 3.12 because core devs were super busy before release :) We did not consider it as a "bug fix" so no backport was done. The PR is #103465.
The core issue is pdb parses c = None as a c, or continue command + = None args, which is what cmd.Cmd (pdb is a subclass of it) does. In the old pdb, there's no argument checking - extra arguments will just be ignored. So c = None is strictly equivalent to c.
We can backport the PR if we want, otherwise this should be marked done. We won't fix 3.9 of course, it does not take bug fixes anymore. The best we can do is to backport the fix to 3.11.
Bug report
Bug description:
Using specific values as variable names in breakpoints leads to incorrect behaviour.
This seems to be because certain chars are used as aliases in pdb, i.e
c
iscontinue
,p
isprint
etc.It is triggered when the following char is non-alpha-numeric, afaict.
MRE:
The same is true for other aliases, like
q
andp
, which raise errors relating to their respective functions. (I have not tried all aliases).CPython versions tested on:
3.9
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: