[Python-checkins] r83272 - in python/branches/py3k: Lib/bdb.py Lib/test/test_pdb.py Misc/NEWS

georg.brandl python-checkins at python.org
Fri Jul 30 12:29:19 CEST 2010


Author: georg.brandl
Date: Fri Jul 30 12:29:19 2010
New Revision: 83272

Log:
#5294: Fix the behavior of pdb "continue" command when called in the top-level debugged frame.

Modified:
   python/branches/py3k/Lib/bdb.py
   python/branches/py3k/Lib/test/test_pdb.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/bdb.py
==============================================================================
--- python/branches/py3k/Lib/bdb.py	(original)
+++ python/branches/py3k/Lib/bdb.py	Fri Jul 30 12:29:19 2010
@@ -109,6 +109,8 @@
                self.is_skipped_module(frame.f_globals.get('__name__')):
             return False
         if frame is self.stopframe:
+            if self.stoplineno == -1:
+                return False
             return frame.f_lineno >= self.stoplineno
         while frame is not None and frame is not self.stopframe:
             if frame is self.botframe:
@@ -165,10 +167,12 @@
         but only if we are to stop at or just below this level."""
         pass
 
-    def _set_stopinfo(self, stopframe, returnframe, stoplineno=-1):
+    def _set_stopinfo(self, stopframe, returnframe, stoplineno=0):
         self.stopframe = stopframe
         self.returnframe = returnframe
         self.quitting = 0
+        # stoplineno >= 0 means: stop at line >= the stoplineno
+        # stoplineno -1 means: don't stop at all
         self.stoplineno = stoplineno
 
     # Derived classes and clients can call the following methods
@@ -184,7 +188,7 @@
 
     def set_step(self):
         """Stop after one line of code."""
-        self._set_stopinfo(None,None)
+        self._set_stopinfo(None, None)
 
     def set_next(self, frame):
         """Stop on the next line in or below the given frame."""
@@ -211,7 +215,7 @@
 
     def set_continue(self):
         # Don't stop except at breakpoints or when finished
-        self._set_stopinfo(self.botframe, None)
+        self._set_stopinfo(self.botframe, None, -1)
         if not self.breaks:
             # no breakpoints; run without debugger overhead
             sys.settrace(None)

Modified: python/branches/py3k/Lib/test/test_pdb.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pdb.py	(original)
+++ python/branches/py3k/Lib/test/test_pdb.py	Fri Jul 30 12:29:19 2010
@@ -122,6 +122,48 @@
     """
 
 
+def test_pdb_continue_in_bottomframe():
+    """Test that "continue" and "next" work properly in bottom frame (issue #5294).
+
+    >>> def test_function():
+    ...     import pdb, sys; inst = pdb.Pdb()
+    ...     inst.set_trace()
+    ...     inst.botframe = sys._getframe()  # hackery to get the right botframe
+    ...     print(1)
+    ...     print(2)
+    ...     print(3)
+    ...     print(4)
+
+    >>> with PdbTestInput([
+    ...     'next',
+    ...     'break 7',
+    ...     'continue',
+    ...     'next',
+    ...     'continue',
+    ...     'continue',
+    ... ]):
+    ...    test_function()
+    > <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>(4)test_function()
+    -> inst.botframe = sys._getframe()  # hackery to get the right botframe
+    (Pdb) next
+    > <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>(5)test_function()
+    -> print(1)
+    (Pdb) break 7
+    Breakpoint 1 at <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>:7
+    (Pdb) continue
+    1
+    2
+    > <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>(7)test_function()
+    -> print(3)
+    (Pdb) next
+    3
+    > <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>(8)test_function()
+    -> print(4)
+    (Pdb) continue
+    4
+    """
+
+
 def pdb_invoke(method, arg):
     """Run pdb.method(arg)."""
     import pdb; getattr(pdb, method)(arg)

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Fri Jul 30 12:29:19 2010
@@ -475,6 +475,9 @@
 Library
 -------
 
+- Issue #5294: Fix the behavior of pdb's "continue" command when called
+  in the top-level debugged frame.
+
 - Issue #5727: Restore the ability to use readline when calling into pdb
   in doctests.
 


More information about the Python-checkins mailing list