mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
GH-101673: Fix pdb bug where local variable changes are lost after longlist (#101674)
This commit is contained in:
parent
f6ca71a422
commit
5d677c556f
3 changed files with 32 additions and 11 deletions
13
Lib/pdb.py
13
Lib/pdb.py
|
|
@ -107,15 +107,6 @@ def find_function(funcname, filename):
|
|||
return funcname, filename, lineno
|
||||
return None
|
||||
|
||||
def getsourcelines(obj):
|
||||
lines, lineno = inspect.findsource(obj)
|
||||
if inspect.isframe(obj) and obj.f_globals is obj.f_locals:
|
||||
# must be a module frame: do not try to cut a block out of it
|
||||
return lines, 1
|
||||
elif inspect.ismodule(obj):
|
||||
return lines, 1
|
||||
return inspect.getblock(lines[lineno:]), lineno+1
|
||||
|
||||
def lasti2lineno(code, lasti):
|
||||
linestarts = list(dis.findlinestarts(code))
|
||||
linestarts.reverse()
|
||||
|
|
@ -1357,7 +1348,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
|||
filename = self.curframe.f_code.co_filename
|
||||
breaklist = self.get_file_breaks(filename)
|
||||
try:
|
||||
lines, lineno = getsourcelines(self.curframe)
|
||||
lines, lineno = inspect.getsourcelines(self.curframe)
|
||||
except OSError as err:
|
||||
self.error(err)
|
||||
return
|
||||
|
|
@ -1373,7 +1364,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
|
|||
except:
|
||||
return
|
||||
try:
|
||||
lines, lineno = getsourcelines(obj)
|
||||
lines, lineno = inspect.getsourcelines(obj)
|
||||
except (OSError, TypeError) as err:
|
||||
self.error(err)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue