]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-59000: Fix pdb breakpoint resolution for class methods when module not imported...
authorLloydZ <35182391+cocolato@users.noreply.github.com>
Tue, 2 Dec 2025 04:41:54 +0000 (12:41 +0800)
committerGitHub <noreply@github.com>
Tue, 2 Dec 2025 04:41:54 +0000 (20:41 -0800)
Lib/pdb.py
Lib/test/test_pdb.py
Misc/NEWS.d/next/Library/2025-11-25-16-00-29.gh-issue-59000.YtOyJy.rst [new file with mode: 0644]

index 60b713ebaf3d1a85d89b86472768d7bd4bc6494c..18cee7e9ae60e169292c8c71fa66ce31d6184d29 100644 (file)
@@ -1487,7 +1487,9 @@ class Pdb(bdb.Bdb, cmd.Cmd):
             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
 
index 34dfc220c7ed733f324eb145011a52f7f4a53779..8d5827424998154341b4c4868226fb9bdeeda614 100644 (file)
@@ -4587,6 +4587,22 @@ def bœr():
             ]))
             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):
diff --git a/Misc/NEWS.d/next/Library/2025-11-25-16-00-29.gh-issue-59000.YtOyJy.rst b/Misc/NEWS.d/next/Library/2025-11-25-16-00-29.gh-issue-59000.YtOyJy.rst
new file mode 100644 (file)
index 0000000..33ab8a0
--- /dev/null
@@ -0,0 +1 @@
+Fix :mod:`pdb` breakpoint resolution for class methods when the module defining the class is not imported.\r