Skip to content

Commit dd2ad70

Browse files
[3.13] gh-127321: Avoid stopping at an opcode without an associated line number for breakpoint() (GH-127457) (#127487)
(cherry picked from commit 1bc4f07)
1 parent 3b31f8c commit dd2ad70

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
@@ -436,6 +436,13 @@ def user_line(self, frame):
436436
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)):
437437
return
438438
self._wait_for_mainpyfile = False
439+
if self.trace_opcodes:
440+
# GH-127321
441+
# We want to avoid stopping at an opcode that does not have
442+
# an associated line number because pdb does not like it
443+
if frame.f_lineno is None:
444+
self.set_stepinstr()
445+
return
439446
if self.bp_commands(frame):
440447
self.interaction(frame, None)
441448

Lib/test/test_pdb.py

+16
Original file line numberDiff line numberDiff line change
@@ -2719,6 +2719,22 @@ def test_pdb_issue_gh_108976():
27192719
(Pdb) continue
27202720
"""
27212721

2722+
def test_pdb_issue_gh_127321():
2723+
"""See GH-127321
2724+
breakpoint() should stop at a opcode that has a line number
2725+
>>> def test_function():
2726+
... import pdb; pdb_instance = pdb.Pdb(nosigint=True, readrc=False)
2727+
... [1, 2] and pdb_instance.set_trace()
2728+
... a = 1
2729+
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
2730+
... 'continue'
2731+
... ]):
2732+
... test_function()
2733+
> <doctest test.test_pdb.test_pdb_issue_gh_127321[0]>(4)test_function()
2734+
-> a = 1
2735+
(Pdb) continue
2736+
"""
2737+
27222738

27232739
def test_pdb_issue_gh_80731():
27242740
"""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)