mirror of https://github.com/python/cpython
gh-109375: Fix bug where pdb registers an alias without an associated command (#109376)
This commit is contained in:
parent
e091b9f20f
commit
68a6f21f47
|
@ -1753,8 +1753,11 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
|||
for alias in keys:
|
||||
self.message("%s = %s" % (alias, self.aliases[alias]))
|
||||
return
|
||||
if args[0] in self.aliases and len(args) == 1:
|
||||
self.message("%s = %s" % (args[0], self.aliases[args[0]]))
|
||||
if len(args) == 1:
|
||||
if args[0] in self.aliases:
|
||||
self.message("%s = %s" % (args[0], self.aliases[args[0]]))
|
||||
else:
|
||||
self.error(f"Unknown alias '{args[0]}'")
|
||||
else:
|
||||
self.aliases[args[0]] = ' '.join(args[1:])
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
@ -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
|
||||
*** Unknown alias 'pi'
|
||||
(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
|
||||
|
|
|
@ -254,6 +254,7 @@ Curtis Bucher
|
|||
Colm Buckley
|
||||
Erik de Bueger
|
||||
Jan-Hein Bührman
|
||||
Marc Bürg
|
||||
Lars Buitinck
|
||||
Artem Bulgakov
|
||||
Dick Bulterman
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
The :mod:`pdb` ``alias`` command now prevents registering aliases without arguments.
|
Loading…
Reference in New Issue