https://github.com/python/cpython/commit/eef49c359505eaf109d519d39e53dfd3c78d066a
commit: eef49c359505eaf109d519d39e53dfd3c78d066a
branch: main
author: Tian Gao <[email protected]>
committer: gaogaotiantian <[email protected]>
date: 2025-04-24T16:07:27-04:00
summary:
gh-93696: Fixed the breakpoint display error for frozen modules (#132862)
files:
A Misc/NEWS.d/next/Library/2025-04-24-01-03-40.gh-issue-93696.kM-MBp.rst
M Lib/pdb.py
M Lib/test/test_pdb.py
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 160a7043a30c55..38a2fbceccc82b 100644
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -1971,12 +1971,6 @@ def do_list(self, arg):
if last is None:
last = first + 10
filename = self.curframe.f_code.co_filename
- # gh-93696: stdlib frozen modules provide a useful __file__
- # this workaround can be removed with the closure of gh-89815
- if filename.startswith("<frozen"):
- tmp = self.curframe.f_globals.get("__file__")
- if isinstance(tmp, str):
- filename = tmp
breaklist = self.get_file_breaks(filename)
try:
lines = linecache.getlines(filename, self.curframe.f_globals)
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index db79dcd6e65230..60a41becea4ca1 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -4260,13 +4260,22 @@ def _create_fake_frozen_module():
mod = _create_fake_frozen_module()
mod.func()
"""
- commands = """
+ commands_list = """
break 20
continue
step
+ break 4
list
quit
"""
+ commands_longlist = """
+ break 20
+ continue
+ step
+ break 4
+ longlist
+ quit
+ """
with open('gh93696.py', 'w') as f:
f.write(textwrap.dedent(frozen_src))
@@ -4275,9 +4284,14 @@ def _create_fake_frozen_module():
self.addCleanup(os_helper.unlink, 'gh93696.py')
self.addCleanup(os_helper.unlink, 'gh93696_host.py')
- stdout, stderr = self._run_pdb(["gh93696_host.py"], commands)
- # verify that pdb found the source of the "frozen" function
- self.assertIn('x = "Sentinel string for gh-93696"', stdout, "Sentinel
statement not found")
+
+ # verify that pdb found the source of the "frozen" function and it
+ # shows the breakpoint at the correct line for both list and longlist
+ for commands in (commands_list, commands_longlist):
+ stdout, _ = self._run_pdb(["gh93696_host.py"], commands)
+ self.assertIn('x = "Sentinel string for gh-93696"', stdout,
"Sentinel statement not found")
+ self.assertIn('4 B', stdout, "breakpoint not found")
+ self.assertIn('-> def func():', stdout, "stack entry not found")
def test_empty_file(self):
script = ''
diff --git
a/Misc/NEWS.d/next/Library/2025-04-24-01-03-40.gh-issue-93696.kM-MBp.rst
b/Misc/NEWS.d/next/Library/2025-04-24-01-03-40.gh-issue-93696.kM-MBp.rst
new file mode 100644
index 00000000000000..61448a85a3db55
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-04-24-01-03-40.gh-issue-93696.kM-MBp.rst
@@ -0,0 +1 @@
+Fixed the breakpoint display error for frozen modules in :mod:`pdb`.
_______________________________________________
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]