[Python-checkins] r83261 - python/branches/py3k/Lib/pdb.py

georg.brandl python-checkins at python.org
Fri Jul 30 09:21:26 CEST 2010


Author: georg.brandl
Date: Fri Jul 30 09:21:26 2010
New Revision: 83261

Log:
#9230: allow Pdb.checkline() to be called without a current frame, for setting breakpoints before starting debugging.

Modified:
   python/branches/py3k/Lib/pdb.py

Modified: python/branches/py3k/Lib/pdb.py
==============================================================================
--- python/branches/py3k/Lib/pdb.py	(original)
+++ python/branches/py3k/Lib/pdb.py	Fri Jul 30 09:21:26 2010
@@ -675,7 +675,10 @@
         Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank
         line or EOF). Warning: testing is not comprehensive.
         """
-        line = linecache.getline(filename, lineno, self.curframe.f_globals)
+        # this method should be callable before starting debugging, so default
+        # to "no globals" if there is no current frame
+        globs = self.curframe.f_globals if hasattr(self, 'curframe') else None
+        line = linecache.getline(filename, lineno, globs)
         if not line:
             print('End of file', file=self.stdout)
             return 0
@@ -1514,7 +1517,7 @@
     # changed by the user from the command line. There is a "restart" command
     # which allows explicit specification of command line arguments.
     pdb = Pdb()
-    while 1:
+    while True:
         try:
             pdb._runscript(mainpyfile)
             if pdb._user_requested_quit:


More information about the Python-checkins mailing list