Skip to content

[3.13] gh-127321: Avoid stopping at an opcode without an associated line number for breakpoint() (GH-127457) #127487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,13 @@ def user_line(self, frame):
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)):
return
self._wait_for_mainpyfile = False
if self.trace_opcodes:
# GH-127321
# We want to avoid stopping at an opcode that does not have
# an associated line number because pdb does not like it
if frame.f_lineno is None:
self.set_stepinstr()
return
if self.bp_commands(frame):
self.interaction(frame, None)

Expand Down
16 changes: 16 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2719,6 +2719,22 @@ def test_pdb_issue_gh_108976():
(Pdb) continue
"""

def test_pdb_issue_gh_127321():
"""See GH-127321
breakpoint() should stop at a opcode that has a line number
>>> def test_function():
... import pdb; pdb_instance = pdb.Pdb(nosigint=True, readrc=False)
... [1, 2] and pdb_instance.set_trace()
... a = 1
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
... 'continue'
... ]):
... test_function()
> <doctest test.test_pdb.test_pdb_issue_gh_127321[0]>(4)test_function()
-> a = 1
(Pdb) continue
"""


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