From 3e1227e2af3a693f888087e4b883715923c1a563 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Wed, 23 Apr 2025 20:58:10 -0400 Subject: [PATCH 1/3] Fixed the breakpoint display error for frozen modules --- Lib/pdb.py | 6 ------ Lib/test/test_pdb.py | 24 +++++++++++++++++++++--- 2 files changed, 21 insertions(+), 9 deletions(-) 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(" def func():', stdout, "stack entry not found") + + stdout, _ = self._run_pdb(["gh93696_host.py"], commands_longlist) 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 = '' From f10fc24a7d658196e21094cebf9f2621eee98a8f Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 24 Apr 2025 01:03:43 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2025-04-24-01-03-40.gh-issue-93696.kM-MBp.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2025-04-24-01-03-40.gh-issue-93696.kM-MBp.rst 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`. From a9fa111edb63548fb0719581c0a9ed030bfca23d Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Thu, 24 Apr 2025 14:50:07 -0400 Subject: [PATCH 3/3] Use loop for testing --- Lib/test/test_pdb.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index fc6624df6e84aa..60a41becea4ca1 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -4287,15 +4287,11 @@ def _create_fake_frozen_module(): # verify that pdb found the source of the "frozen" function and it # shows the breakpoint at the correct line for both list and longlist - stdout, _ = self._run_pdb(["gh93696_host.py"], commands_list) - 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") - - stdout, _ = self._run_pdb(["gh93696_host.py"], commands_longlist) - 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") + 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 = ''