mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
#9064: accept number of frames for "up" and "down" commands in pdb.
This commit is contained in:
parent
952867aa30
commit
eb1f4aa232
4 changed files with 42 additions and 20 deletions
|
@ -210,11 +210,13 @@ w(here)
|
||||||
Print a stack trace, with the most recent frame at the bottom. An arrow
|
Print a stack trace, with the most recent frame at the bottom. An arrow
|
||||||
indicates the current frame, which determines the context of most commands.
|
indicates the current frame, which determines the context of most commands.
|
||||||
|
|
||||||
d(own)
|
d(own) [*count*]
|
||||||
Move the current frame one level down in the stack trace (to a newer frame).
|
Move the current frame *count* (default one) levels down in the stack trace
|
||||||
|
(to a newer frame).
|
||||||
|
|
||||||
u(p)
|
u(p) [*count*]
|
||||||
Move the current frame one level up in the stack trace (to an older frame).
|
Move the current frame *count* (default one) levels up in the stack trace
|
||||||
|
(to an older frame).
|
||||||
|
|
||||||
b(reak) [[*filename*:]\ *lineno* | *function*\ [, *condition*]]
|
b(reak) [[*filename*:]\ *lineno* | *function*\ [, *condition*]]
|
||||||
With a *lineno* argument, set a break there in the current file. With a
|
With a *lineno* argument, set a break there in the current file. With a
|
||||||
|
|
12
Lib/pdb.doc
12
Lib/pdb.doc
|
@ -68,13 +68,13 @@ w(here)
|
||||||
An arrow indicates the "current frame", which determines the
|
An arrow indicates the "current frame", which determines the
|
||||||
context of most commands.
|
context of most commands.
|
||||||
|
|
||||||
d(own)
|
d(own) [ count ]
|
||||||
Move the current frame one level down in the stack trace
|
Move the current frame count (default one) levels down in the
|
||||||
(to a newer frame).
|
stack trace (to a newer frame).
|
||||||
|
|
||||||
u(p)
|
u(p) [ count ]
|
||||||
Move the current frame one level up in the stack trace
|
Move the current frame count (default one) levels up in the
|
||||||
(to an older frame).
|
stack trace (to an older frame).
|
||||||
|
|
||||||
b(reak) [ ([filename:]lineno | function) [, condition] ]
|
b(reak) [ ([filename:]lineno | function) [, condition] ]
|
||||||
With a filename:line number argument, set a break there. If
|
With a filename:line number argument, set a break there. If
|
||||||
|
|
38
Lib/pdb.py
38
Lib/pdb.py
|
@ -618,26 +618,44 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
do_w = do_where
|
do_w = do_where
|
||||||
do_bt = do_where
|
do_bt = do_where
|
||||||
|
|
||||||
def do_up(self, arg):
|
def _select_frame(self, number):
|
||||||
if self.curindex == 0:
|
assert 0 <= number < len(self.stack)
|
||||||
print('*** Oldest frame', file=self.stdout)
|
self.curindex = number
|
||||||
else:
|
|
||||||
self.curindex = self.curindex - 1
|
|
||||||
self.curframe = self.stack[self.curindex][0]
|
self.curframe = self.stack[self.curindex][0]
|
||||||
self.curframe_locals = self.curframe.f_locals
|
self.curframe_locals = self.curframe.f_locals
|
||||||
self.print_stack_entry(self.stack[self.curindex])
|
self.print_stack_entry(self.stack[self.curindex])
|
||||||
self.lineno = None
|
self.lineno = None
|
||||||
|
|
||||||
|
def do_up(self, arg):
|
||||||
|
if self.curindex == 0:
|
||||||
|
print('*** Oldest frame', file=self.stdout)
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
count = int(arg or 1)
|
||||||
|
except ValueError:
|
||||||
|
print('*** Invalid frame count (%s)' % arg, file=self.stdout)
|
||||||
|
return
|
||||||
|
if count < 0:
|
||||||
|
newframe = 0
|
||||||
|
else:
|
||||||
|
newframe = max(0, self.curindex - count)
|
||||||
|
self._select_frame(newframe)
|
||||||
do_u = do_up
|
do_u = do_up
|
||||||
|
|
||||||
def do_down(self, arg):
|
def do_down(self, arg):
|
||||||
if self.curindex + 1 == len(self.stack):
|
if self.curindex + 1 == len(self.stack):
|
||||||
print('*** Newest frame', file=self.stdout)
|
print('*** Newest frame', file=self.stdout)
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
count = int(arg or 1)
|
||||||
|
except ValueError:
|
||||||
|
print('*** Invalid frame count (%s)' % arg, file=self.stdout)
|
||||||
|
return
|
||||||
|
if count < 0:
|
||||||
|
newframe = len(self.stack) - 1
|
||||||
else:
|
else:
|
||||||
self.curindex = self.curindex + 1
|
newframe = min(len(self.stack) - 1, self.curindex + count)
|
||||||
self.curframe = self.stack[self.curindex][0]
|
self._select_frame(newframe)
|
||||||
self.curframe_locals = self.curframe.f_locals
|
|
||||||
self.print_stack_entry(self.stack[self.curindex])
|
|
||||||
self.lineno = None
|
|
||||||
do_d = do_down
|
do_d = do_down
|
||||||
|
|
||||||
def do_until(self, arg):
|
def do_until(self, arg):
|
||||||
|
|
|
@ -456,6 +456,8 @@ C-API
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #9064: pdb's "up" and "down" commands now accept an optional argument.
|
||||||
|
|
||||||
- Issue #9018: os.path.normcase() now raises a TypeError if the argument is
|
- Issue #9018: os.path.normcase() now raises a TypeError if the argument is
|
||||||
not ``str`` or ``bytes``.
|
not ``str`` or ``bytes``.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue