Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pdb: calling registered alias without command raises KeyError #109375

Closed
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@buermarc

Description

@buermarc

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp