summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-07-30 07:21:26 (GMT)
committerGeorg Brandl <georg@python.org>2010-07-30 07:21:26 (GMT)
commit1e30bd3753e7b08dce13ff1e18ac1ae5c397fcea (patch)
treebd3e837b29883e83daad6b91cda3876fb63bfae5
parenta91a94b7c054a01b26bc76a1f3ccaefc6395f077 (diff)
downloadcpython-1e30bd3753e7b08dce13ff1e18ac1ae5c397fcea.zip
cpython-1e30bd3753e7b08dce13ff1e18ac1ae5c397fcea.tar.gz
cpython-1e30bd3753e7b08dce13ff1e18ac1ae5c397fcea.tar.bz2
#9230: allow Pdb.checkline() to be called without a current frame, for setting breakpoints before starting debugging.
-rwxr-xr-xLib/pdb.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index feca2b3..b775a12 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -675,7 +675,10 @@ class Pdb(bdb.Bdb, cmd.Cmd):
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 @@ def main():
# 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: