From 7d8ada33150193880395d9ae94d83cd55787d3fb Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Sat, 30 Nov 2024 16:42:24 -0500 Subject: [PATCH 1/3] Avoid stopping at an opcode without an associated line number for breakpoint() --- Lib/pdb.py | 7 +++++++ Lib/test/test_pdb.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Lib/pdb.py b/Lib/pdb.py index b7f6fd4323407e..10d1923cdad2d6 100644 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -438,6 +438,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 self.bp_commands(frame) self.interaction(frame, None) diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index e5f9848319021a..48a4c568651879 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -2931,6 +2931,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() + > (4)test_function() + -> a = 1 + (Pdb) continue + """ + def test_pdb_issue_gh_80731(): """See GH-80731 From ea6e6bb073ae38ed02f95ac3cbcf585d91d5a332 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 30 Nov 2024 21:46:19 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2024-11-30-21-46-15.gh-issue-127321.M78fBv.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2024-11-30-21-46-15.gh-issue-127321.M78fBv.rst diff --git a/Misc/NEWS.d/next/Library/2024-11-30-21-46-15.gh-issue-127321.M78fBv.rst b/Misc/NEWS.d/next/Library/2024-11-30-21-46-15.gh-issue-127321.M78fBv.rst new file mode 100644 index 00000000000000..167d9445d57fba --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-11-30-21-46-15.gh-issue-127321.M78fBv.rst @@ -0,0 +1 @@ +:func:`pdb.set_trace()` will not stop at an opcode that does not have an associated line number anymore. From bfe19a7cbbfcf7a6cb2ff01117fc56b921810570 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Sat, 30 Nov 2024 20:27:46 -0500 Subject: [PATCH 3/3] Update 2024-11-30-21-46-15.gh-issue-127321.M78fBv.rst --- .../next/Library/2024-11-30-21-46-15.gh-issue-127321.M78fBv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-11-30-21-46-15.gh-issue-127321.M78fBv.rst b/Misc/NEWS.d/next/Library/2024-11-30-21-46-15.gh-issue-127321.M78fBv.rst index 167d9445d57fba..69b6ce68a47509 100644 --- a/Misc/NEWS.d/next/Library/2024-11-30-21-46-15.gh-issue-127321.M78fBv.rst +++ b/Misc/NEWS.d/next/Library/2024-11-30-21-46-15.gh-issue-127321.M78fBv.rst @@ -1 +1 @@ -:func:`pdb.set_trace()` will not stop at an opcode that does not have an associated line number anymore. +:func:`pdb.set_trace` will not stop at an opcode that does not have an associated line number anymore.