Skip to content

Commit 5e58548

Browse files
authored
gh-59000: Fix pdb breakpoint resolution for class methods when module not imported (#141949)
1 parent 4172885 commit 5e58548

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
@@ -1487,7 +1487,9 @@ def lineinfo(self, identifier):
14871487
f = self.lookupmodule(parts[0])
14881488
if f:
14891489
fname = f
1490-
item = parts[1]
1490+
item = parts[1]
1491+
else:
1492+
return failed
14911493
answer = find_function(item, self.canonic(fname))
14921494
return answer or failed
14931495

Lib/test/test_pdb.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4587,6 +4587,22 @@ def bar():
45874587
]))
45884588
self.assertIn('break in bar', stdout)
45894589

4590+
def test_issue_59000(self):
4591+
script = """
4592+
def foo():
4593+
pass
4594+
4595+
class C:
4596+
def foo(self):
4597+
pass
4598+
"""
4599+
commands = """
4600+
break C.foo
4601+
quit
4602+
"""
4603+
stdout, stderr = self.run_pdb_script(script, commands)
4604+
self.assertIn("The specified object 'C.foo' is not a function", stdout)
4605+
45904606

45914607
class ChecklineTests(unittest.TestCase):
45924608
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)