https://github.com/python/cpython/commit/15a25f44ee82d67e8c11f78765007ff786b6bfef
commit: 15a25f44ee82d67e8c11f78765007ff786b6bfef
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: gaogaotiantian <[email protected]>
date: 2025-12-02T05:06:26Z
summary:

[3.14] gh-59000: Fix pdb breakpoint resolution for class methods when module 
not imported (GH-141949) (#142171)

gh-59000: Fix pdb breakpoint resolution for class methods when module not 
imported (GH-141949)
(cherry picked from commit 5e58548ebe8f7ac8c6cb0bad775912caa4090515)

Co-authored-by: LloydZ <[email protected]>

files:
A Misc/NEWS.d/next/Library/2025-11-25-16-00-29.gh-issue-59000.YtOyJy.rst
M Lib/pdb.py
M Lib/test/test_pdb.py

diff --git a/Lib/pdb.py b/Lib/pdb.py
index fa5b14ccb9271b..01f8f7487233af 100644
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -1481,7 +1481,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
 
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 9d89008756a1d3..b1b8c7d49befde 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -4573,6 +4573,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):
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
index 00000000000000..33ab8a0659e4a2
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-11-25-16-00-29.gh-issue-59000.YtOyJy.rst
@@ -0,0 +1 @@
+Fix :mod:`pdb` breakpoint resolution for class methods when the module 
defining the class is not imported.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to