Skip to content

Commit 9d99b5b

Browse files
[3.13] gh-59000: Fix pdb breakpoint resolution for class methods when… (#142172)
* [3.13] 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 01393ff commit 9d99b5b

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
@@ -1262,7 +1262,9 @@ def lineinfo(self, identifier):
12621262
f = self.lookupmodule(parts[0])
12631263
if f:
12641264
fname = f
1265-
item = parts[1]
1265+
item = parts[1]
1266+
else:
1267+
return failed
12661268
answer = find_function(item, self.canonic(fname))
12671269
return answer or failed
12681270

Lib/test/test_pdb.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4013,6 +4013,22 @@ def f(x):
40134013
self.assertIn('42', stdout)
40144014
self.assertIn('return x + 1', stdout)
40154015

4016+
def test_issue_59000(self):
4017+
script = """
4018+
def foo():
4019+
pass
4020+
4021+
class C:
4022+
def foo(self):
4023+
pass
4024+
"""
4025+
commands = """
4026+
break C.foo
4027+
quit
4028+
"""
4029+
stdout, stderr = self.run_pdb_script(script, commands)
4030+
self.assertIn("The specified object 'C.foo' is not a function", stdout)
4031+
40164032

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