Skip to content

Commit 854dff2

Browse files
gaogaotiantianpicnixz
authored andcommitted
pythongh-127321: Avoid stopping at an opcode without an associated line number for breakpoint() (python#127457)
1 parent c6193a8 commit 854dff2

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

Lib/pdb.py

+7
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,13 @@ def user_line(self, frame):
438438
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)):
439439
return
440440
self._wait_for_mainpyfile = False
441+
if self.trace_opcodes:
442+
# GH-127321
443+
# We want to avoid stopping at an opcode that does not have
444+
# an associated line number because pdb does not like it
445+
if frame.f_lineno is None:
446+
self.set_stepinstr()
447+
return
441448
self.bp_commands(frame)
442449
self.interaction(frame, None)
443450

Lib/test/test_pdb.py

+16
Original file line numberDiff line numberDiff line change
@@ -2931,6 +2931,22 @@ def test_pdb_issue_gh_108976():
29312931
(Pdb) continue
29322932
"""
29332933

2934+
def test_pdb_issue_gh_127321():
2935+
"""See GH-127321
2936+
breakpoint() should stop at a opcode that has a line number
2937+
>>> def test_function():
2938+
... import pdb; pdb_instance = pdb.Pdb(nosigint=True, readrc=False)
2939+
... [1, 2] and pdb_instance.set_trace()
2940+
... a = 1
2941+
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
2942+
... 'continue'
2943+
... ]):
2944+
... test_function()
2945+
> <doctest test.test_pdb.test_pdb_issue_gh_127321[0]>(4)test_function()
2946+
-> a = 1
2947+
(Pdb) continue
2948+
"""
2949+
29342950

29352951
def test_pdb_issue_gh_80731():
29362952
"""See GH-80731
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:func:`pdb.set_trace` will not stop at an opcode that does not have an associated line number anymore.

0 commit comments

Comments
 (0)