Skip to content

Commit 15a25f4

Browse files
[3.14] gh-59000: Fix pdb breakpoint resolution for class methods when module not imported (GH-141949) (#142171)
gh-59000: Fix pdb breakpoint resolution for class methods when module not imported (GH-141949) (cherry picked from commit 5e58548) Co-authored-by: LloydZ <35182391+cocolato@users.noreply.github.com>
1 parent 5c5670e commit 15a25f4

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

Lib/pdb.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,9 @@ def lineinfo(self, identifier):
14811481
f = self.lookupmodule(parts[0])
14821482
if f:
14831483
fname = f
1484-
item = parts[1]
1484+
item = parts[1]
1485+
else:
1486+
return failed
14851487
answer = find_function(item, self.canonic(fname))
14861488
return answer or failed
14871489

Lib/test/test_pdb.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4573,6 +4573,22 @@ def bar():
45734573
]))
45744574
self.assertIn('break in bar', stdout)
45754575

4576+
def test_issue_59000(self):
4577+
script = """
4578+
def foo():
4579+
pass
4580+
4581+
class C:
4582+
def foo(self):
4583+
pass
4584+
"""
4585+
commands = """
4586+
break C.foo
4587+
quit
4588+
"""
4589+
stdout, stderr = self.run_pdb_script(script, commands)
4590+
self.assertIn("The specified object 'C.foo' is not a function", stdout)
4591+
45764592

45774593
class ChecklineTests(unittest.TestCase):
45784594
def setUp(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :mod:`pdb` breakpoint resolution for class methods when the module defining the class is not imported.

0 commit comments

Comments
 (0)