Skip to content
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

Pdb bug when using names that collide w/ aliases of breakpoints operations #111352

Closed
JosephSBoyle opened this issue Oct 26, 2023 · 3 comments
Closed
Labels
type-bug An unexpected behavior, bug, or error

Comments

@JosephSBoyle
Copy link
Contributor

JosephSBoyle commented Oct 26, 2023

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 is continue, p is print etc.
It is triggered when the following char is non-alpha-numeric, afaict.

MRE:

Python 3.9.5 (default, Sep 14 2021, 12:04:19) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> breakpoint()
--Return--
> <stdin>(1)<module>()->None
(Pdb) c = None
>>> c
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'c' is not defined
>>> 
# 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

@JosephSBoyle JosephSBoyle added the type-bug An unexpected behavior, bug, or error label Oct 26, 2023
@AlexWaygood
Copy link
Member

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)

@gaogaotiantian
Copy link
Member

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.

@AlexWaygood
Copy link
Member

Yeah, I think I agree that this is probably a new feature rather than a bugfix. So... wait for Python 3.13, I guess :)

Sorry we can't do better than that here @JosephSBoyle!

@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants