mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
A working version of the 'args' command (it prints the current values
of the variables known to hold arguments, but that's as close as I can get, and generally it's close enough).
This commit is contained in:
parent
d151d34ebd
commit
46c86bbca9
1 changed files with 12 additions and 5 deletions
17
Lib/pdb.py
17
Lib/pdb.py
|
@ -201,10 +201,17 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
do_q = do_quit
|
do_q = do_quit
|
||||||
|
|
||||||
def do_args(self, arg):
|
def do_args(self, arg):
|
||||||
if self.curframe.f_locals.has_key('__args__'):
|
f = self.curframe
|
||||||
print `self.curframe.f_locals['__args__']`
|
co = f.f_code
|
||||||
else:
|
dict = f.f_locals
|
||||||
print '*** No arguments?!'
|
n = co.co_argcount
|
||||||
|
if co.co_flags & 4: n = n+1
|
||||||
|
if co.co_flags & 8: n = n+1
|
||||||
|
for i in range(n):
|
||||||
|
name = co.co_varnames[i]
|
||||||
|
print name, '=',
|
||||||
|
if dict.has_key(name): print dict[name]
|
||||||
|
else: print "*** undefined ***"
|
||||||
do_a = do_args
|
do_a = do_args
|
||||||
|
|
||||||
def do_retval(self, arg):
|
def do_retval(self, arg):
|
||||||
|
@ -432,7 +439,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
|
|
||||||
def help_a(self):
|
def help_a(self):
|
||||||
print """a(rgs)
|
print """a(rgs)
|
||||||
Print the argument list of the current function."""
|
Print the arguments of the current function."""
|
||||||
|
|
||||||
def help_p(self):
|
def help_p(self):
|
||||||
print """p expression
|
print """p expression
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue