mirror of
https://github.com/python/cpython.git
synced 2025-09-28 19:25:27 +00:00
#9230: allow Pdb.checkline() to be called without a current frame, for setting breakpoints before starting debugging.
This commit is contained in:
parent
a91a94b7c0
commit
1e30bd3753
1 changed files with 5 additions and 2 deletions
|
@ -675,7 +675,10 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
||||||
Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank
|
Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank
|
||||||
line or EOF). Warning: testing is not comprehensive.
|
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:
|
if not line:
|
||||||
print('End of file', file=self.stdout)
|
print('End of file', file=self.stdout)
|
||||||
return 0
|
return 0
|
||||||
|
@ -1514,7 +1517,7 @@ def main():
|
||||||
# changed by the user from the command line. There is a "restart" command
|
# changed by the user from the command line. There is a "restart" command
|
||||||
# which allows explicit specification of command line arguments.
|
# which allows explicit specification of command line arguments.
|
||||||
pdb = Pdb()
|
pdb = Pdb()
|
||||||
while 1:
|
while True:
|
||||||
try:
|
try:
|
||||||
pdb._runscript(mainpyfile)
|
pdb._runscript(mainpyfile)
|
||||||
if pdb._user_requested_quit:
|
if pdb._user_requested_quit:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue