Skip to content

Commit 88b9e45

Browse files
committed
gh-109375: Fix pdb alias command
An unkown alias without a given command should not register a new alias.
1 parent 0e76cc3 commit 88b9e45

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Lib/pdb.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,8 @@ def do_alias(self, arg):
17551755
return
17561756
if args[0] in self.aliases and len(args) == 1:
17571757
self.message("%s = %s" % (args[0], self.aliases[args[0]]))
1758+
elif len(args) == 1:
1759+
self.error("Unkown alias. To create an alias see 'help alias'")
17581760
else:
17591761
self.aliases[args[0]] = ' '.join(args[1:])
17601762

Lib/test/test_pdb.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,10 @@ def test_pdb_alias_command():
664664
... o.method()
665665
666666
>>> with PdbTestInput([ # doctest: +ELLIPSIS
667+
... 'alias pi',
667668
... 'alias pi for k in %1.__dict__.keys(): print(f"%1.{k} = {%1.__dict__[k]}")',
668669
... 'alias ps pi self',
670+
... 'alias ps',
669671
... 'pi o',
670672
... 's',
671673
... 'ps',
@@ -674,8 +676,12 @@ def test_pdb_alias_command():
674676
... test_function()
675677
> <doctest test.test_pdb.test_pdb_alias_command[1]>(4)test_function()
676678
-> o.method()
679+
(Pdb) alias pi
680+
*** Unkown alias. To create an alias see 'help alias'
677681
(Pdb) alias pi for k in %1.__dict__.keys(): print(f"%1.{k} = {%1.__dict__[k]}")
678682
(Pdb) alias ps pi self
683+
(Pdb) alias ps
684+
ps = pi self
679685
(Pdb) pi o
680686
o.attr1 = 10
681687
o.attr2 = str

0 commit comments

Comments
 (0)