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:
pdb allows to register an alias without a command.
Calling that alias raises an unhandled exception.
$ /tmp/ cat bar.pybreakpoint()$ /tmp/ python bar.py --Return-->/tmp/bar.py(1)<module>()->None->breakpoint()(Pdb)alias foo(Pdb) fooTraceback (most recent call last): File"/tmp/bar.py", line 1,in<module>breakpoint() File"/home/home/.pyenv/versions/3.11.1/lib/python3.11/bdb.py", line 94,in trace_dispatchreturn self.dispatch_return(frame, arg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File"/home/home/.pyenv/versions/3.11.1/lib/python3.11/bdb.py", line 153,in dispatch_return self.user_return(frame, arg) File"/home/home/.pyenv/versions/3.11.1/lib/python3.11/pdb.py", line 372,in user_return self.interaction(frame, None) File"/home/home/.pyenv/versions/3.11.1/lib/python3.11/pdb.py", line 435,in interactionself._cmdloop() File"/home/home/.pyenv/versions/3.11.1/lib/python3.11/pdb.py", line 400,in _cmdloopself.cmdloop() File"/home/home/.pyenv/versions/3.11.1/lib/python3.11/cmd.py", line 137,in cmdloop line = self.precmd(line) ^^^^^^^^^^^^^^^^^ File"/home/home/.pyenv/versions/3.11.1/lib/python3.11/pdb.py", line 473,in precmdwhile args[0]in self.aliases:~~~~^^^IndexError: list index out of range
The general syntax ofalias foo is valid, as it allows to print the alias. However, if there is no command registered, calling it fails.
I am unsure if raising an exception is the wanted behavior here. I think providing an error message which indicates that the current alias is unknown could be more appropriate, e.g.:
$ python /tmp/bar.py--Return-->/tmp/bar.py(1)<module>()->None->breakpoint()(Pdb)alias foo*** Unkown alias. To create analias see'help alias'
A solution could be to add an additional check to catch cases where one tries to register an alias without a command.
CPython versions tested on:
3.10, 3.11, CPython main branch
Operating systems tested on:
Linux