]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-59000: Fix pdb breakpoint resolution for class methods when… (#142172)
authorTian Gao <gaogaotiantian@hotmail.com>
Tue, 2 Dec 2025 05:07:52 +0000 (21:07 -0800)
committerGitHub <noreply@github.com>
Tue, 2 Dec 2025 05:07:52 +0000 (05:07 +0000)
* [3.13] 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 a990d60fe1c2fd8c1aec037d001afef31b649be7..063b12cc856c2146e01c316398ea994d1e093b34 100755 (executable)
@@ -1262,7 +1262,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 92a0180ecc9a0624cb9b20187417c437b9e99d72..dd31649ab262c36f0701cea2b921a75c6a1b8f06 100644 (file)
@@ -4013,6 +4013,22 @@ def bœr():
             self.assertIn('42', stdout)
             self.assertIn('return x + 1', 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