]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-59000: Fix pdb breakpoint resolution for class methods when module not...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 2 Dec 2025 05:06:26 +0000 (06:06 +0100)
committerGitHub <noreply@github.com>
Tue, 2 Dec 2025 05:06:26 +0000 (05:06 +0000)
gh-59000: Fix pdb breakpoint resolution for class methods when module not imported (GH-141949)
(cherry picked from commit 5e58548ebe8f7ac8c6cb0bad775912caa4090515)

Co-authored-by: LloydZ <35182391+cocolato@users.noreply.github.com>
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 fa5b14ccb9271b279f2b5eb31cafeb76e63d90c2..01f8f7487233af5167764b969a93602980084588 100644 (file)
@@ -1481,7 +1481,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 9d89008756a1d33798bcc7911e774735463183e6..b1b8c7d49befde5c4f03f4554432984a1e0be161 100644 (file)
@@ -4573,6 +4573,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