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

gh-109375: Fix bug where pdb registers an alias without an associated command #109376

Merged
merged 5 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,8 @@ def do_alias(self, arg):
return
if args[0] in self.aliases and len(args) == 1:
self.message("%s = %s" % (args[0], self.aliases[args[0]]))
elif len(args) == 1:
self.error("Unkown alias. To create an alias see 'help alias'")
buermarc marked this conversation as resolved.
Show resolved Hide resolved
else:
self.aliases[args[0]] = ' '.join(args[1:])

Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,10 @@ def test_pdb_alias_command():
... o.method()

>>> with PdbTestInput([ # doctest: +ELLIPSIS
... 'alias pi',
... 'alias pi for k in %1.__dict__.keys(): print(f"%1.{k} = {%1.__dict__[k]}")',
... 'alias ps pi self',
... 'alias ps',
... 'pi o',
... 's',
... 'ps',
Expand All @@ -674,8 +676,12 @@ def test_pdb_alias_command():
... test_function()
> <doctest test.test_pdb.test_pdb_alias_command[1]>(4)test_function()
-> o.method()
(Pdb) alias pi
*** Unkown alias. To create an alias see 'help alias'
buermarc marked this conversation as resolved.
Show resolved Hide resolved
(Pdb) alias pi for k in %1.__dict__.keys(): print(f"%1.{k} = {%1.__dict__[k]}")
(Pdb) alias ps pi self
(Pdb) alias ps
ps = pi self
(Pdb) pi o
o.attr1 = 10
o.attr2 = str
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The pdb alias builtin now prevents registering aliases without a command.
iritkatriel marked this conversation as resolved.
Show resolved Hide resolved
Loading