gh-59000: Fix pdb breakpoint resolution for class methods when module not imported (#141949)

This commit is contained in:
LloydZ 2025-12-02 12:41:54 +08:00 committed by GitHub
parent 41728856a2
commit 5e58548ebe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 1 deletions

View file

@ -1487,7 +1487,9 @@ def lineinfo(self, identifier):
f = self.lookupmodule(parts[0])
if f:
fname = f
item = parts[1]
item = parts[1]
else:
return failed
answer = find_function(item, self.canonic(fname))
return answer or failed

View file

@ -4587,6 +4587,22 @@ def bar():
]))
self.assertIn('break in bar', stdout)
def test_issue_59000(self):
script = """
def foo():
pass
class C:
def foo(self):
pass
"""
commands = """
break C.foo
quit
"""
stdout, stderr = self.run_pdb_script(script, commands)
self.assertIn("The specified object 'C.foo' is not a function", stdout)
class ChecklineTests(unittest.TestCase):
def setUp(self):

View file

@ -0,0 +1 @@
Fix :mod:`pdb` breakpoint resolution for class methods when the module defining the class is not imported.