To whom he want to set breakpoint on negative line number in pdb
Jach Feng
jfong at ms4.hinet.net
Sat Dec 12 21:17:40 EST 2020
I use .pdbrc file to help debugging. To avoid editing this file frequently when source was modified, I need this feature.
I modify the checkline function in pdb.py from
...
line = linecache.getline(filename, lineno, globs)
if not line:
....
to
...
lines = linecache.getlines(filename, globs)
if lineno < 0: lineno = len(lines) + lineno + 1 # change to a valid positive number, or not
if 1 <= lineno <= len(lines): line = lines[lineno-1]
else: line = ''
if not line:
...
This modification is mostly the copy of the getline function body except the added line. It will not influence the original pdb usage in anyway.
--Jach
More information about the Python-list
mailing list