Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c33144a

Browse files
committedFeb 10, 2023
pythongh-101517: bdb should not lookup linecache with lineno=None
1 parent d40a23c commit c33144a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed
 

‎Lib/bdb.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,10 @@ def format_stack_entry(self, frame_lineno, lprefix=': '):
570570
rv = frame.f_locals['__return__']
571571
s += '->'
572572
s += reprlib.repr(rv)
573-
line = linecache.getline(filename, lineno, frame.f_globals)
574-
if line:
575-
s += lprefix + line.strip()
573+
if lineno is not None:
574+
line = linecache.getline(filename, lineno, frame.f_globals)
575+
if line:
576+
s += lprefix + line.strip()
576577
return s
577578

578579
# The following methods can be called by clients to use

‎Lib/test/test_bdb.py

+6
Original file line numberDiff line numberDiff line change
@@ -1203,5 +1203,11 @@ def main():
12031203
tracer.runcall(tfunc_import)
12041204

12051205

1206+
class TestRegressions(unittest.TestCase):
1207+
def test_format_stack_entry_no_lineno(self):
1208+
# See gh-101517
1209+
Bdb().format_stack_entry((sys._getframe(), None))
1210+
1211+
12061212
if __name__ == "__main__":
12071213
unittest.main()

0 commit comments

Comments
 (0)
Please sign in to comment.