[Python-checkins] r83263 - in python/branches/py3k: Doc/library/pdb.rst Lib/bdb.py Lib/pdb.py Misc/NEWS

georg.brandl python-checkins at python.org
Fri Jul 30 10:43:33 CEST 2010


Author: georg.brandl
Date: Fri Jul 30 10:43:32 2010
New Revision: 83263

Log:
Allow giving an explicit line number to "until".

Modified:
   python/branches/py3k/Doc/library/pdb.rst
   python/branches/py3k/Lib/bdb.py
   python/branches/py3k/Lib/pdb.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Doc/library/pdb.rst
==============================================================================
--- python/branches/py3k/Doc/library/pdb.rst	(original)
+++ python/branches/py3k/Doc/library/pdb.rst	Fri Jul 30 10:43:32 2010
@@ -330,10 +330,14 @@
    executes called functions at (nearly) full speed, only stopping at the next
    line in the current function.)
 
-.. pdbcommand:: unt(il)
+.. pdbcommand:: unt(il) [lineno]
 
-   Continue execution until the line with the line number greater than the
-   current one is reached or when returning from current frame.
+   Without argument, continue execution until the line with a number greater
+   than the current one is reached.
+
+   With a line number, continue execution until a line with a number greater or
+   equal to that is reached.  In both cases, also stop when the current frame
+   returns.
 
 .. pdbcommand:: r(eturn)
 

Modified: python/branches/py3k/Lib/bdb.py
==============================================================================
--- python/branches/py3k/Lib/bdb.py	(original)
+++ python/branches/py3k/Lib/bdb.py	Fri Jul 30 10:43:32 2010
@@ -174,10 +174,13 @@
     # Derived classes and clients can call the following methods
     # to affect the stepping state.
 
-    def set_until(self, frame): #the name "until" is borrowed from gdb
+    def set_until(self, frame, lineno=None):
         """Stop when the line with the line no greater than the current one is
         reached or when returning from current frame"""
-        self._set_stopinfo(frame, frame, frame.f_lineno+1)
+        # the name "until" is borrowed from gdb
+        if lineno is None:
+            lineno = frame.f_lineno + 1
+        self._set_stopinfo(frame, frame, lineno)
 
     def set_step(self):
         """Stop after one line of code."""

Modified: python/branches/py3k/Lib/pdb.py
==============================================================================
--- python/branches/py3k/Lib/pdb.py	(original)
+++ python/branches/py3k/Lib/pdb.py	Fri Jul 30 10:43:32 2010
@@ -71,11 +71,11 @@
         An arrow indicates the "current frame", which determines the
         context of most commands.
 
-d(own) [ count ]
+d(own) [count]
         Move the current frame count (default one) levels down in the
         stack trace (to a newer frame).
 
-u(p) [ count ]
+u(p) [count]
         Move the current frame count (default one) levels up in the
         stack trace (to an older frame).
 
@@ -140,9 +140,12 @@
         Continue execution until the next line in the current function
         is reached or it returns.
 
-unt(il)
-        Continue execution until the line with a number greater than
-        the current one is reached or until the current frame returns.
+unt(il) [lineno]
+        Without argument, continue execution until the line with a
+        number greater than the current one is reached.  With a line
+        number, continue execution until a line with a number greater
+        or equal to that is reached.  In both cases, also stop when
+        the current frame returns.
 
 r(eturn)
         Continue execution until the current function returns.
@@ -883,7 +886,19 @@
     do_d = do_down
 
     def do_until(self, arg):
-        self.set_until(self.curframe)
+        if arg:
+            try:
+                lineno = int(arg)
+            except ValueError:
+                print('*** Error in argument:', repr(arg), file=self.stdout)
+                return
+            if lineno <= self.curframe.f_lineno:
+                print('*** "until" line number is smaller than current '
+                      'line number', file=self.stdout)
+                return
+        else:
+            lineno = None
+        self.set_until(self.curframe, lineno)
         return 1
     do_unt = do_until
 
@@ -1518,8 +1533,8 @@
 -c are executed after commands from .pdbrc files.
 
 To let the script run until an exception occurs, use "-c continue".
-To let the script run until a given line X in the debugged file, use
-"-c 'break X' -c continue"."""
+To let the script run up to a given line X in the debugged file, use
+"-c 'until X'"."""
 
 def main():
     import getopt

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Fri Jul 30 10:43:32 2010
@@ -475,6 +475,8 @@
 Library
 -------
 
+- In pdb, allow giving a line number to the "until" command.
+
 - Issue #1437051: For pdb, allow "continue" and related commands in
   .pdbrc files.  Also, add a command-line option "-c" that runs a
   command as if given in .pdbrc.


More information about the Python-checkins mailing list