summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2024-12-01 16:57:03 (GMT)
committerGitHub <noreply@github.com>2024-12-01 16:57:03 (GMT)
commit1bc4f076d193ad157bdc69a1d62685a15f95113f (patch)
treedb38ce01f5e3aab9d2efaa066509a4d5981956ba /Lib
parenta880358af03d9cab37f7db04385c5a97051b03b6 (diff)
downloadcpython-1bc4f076d193ad157bdc69a1d62685a15f95113f.zip
cpython-1bc4f076d193ad157bdc69a1d62685a15f95113f.tar.gz
cpython-1bc4f076d193ad157bdc69a1d62685a15f95113f.tar.bz2
gh-127321: Avoid stopping at an opcode without an associated line number for breakpoint() (#127457)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/pdb.py7
-rw-r--r--Lib/test/test_pdb.py16
2 files changed, 23 insertions, 0 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index b7f6fd4..10d1923 100644
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -438,6 +438,13 @@ class Pdb(bdb.Bdb, cmd.Cmd):
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 e5f9848..48a4c56 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()
+ > <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