From 697f0eb690a9accb6da479ede467b556d7dcbfdd Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Thu, 24 Oct 2024 21:50:22 -0400 Subject: [PATCH 1/6] Provide curframe_locals for backward compatibility but deprecate it --- Lib/pdb.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Lib/pdb.py b/Lib/pdb.py index cd7a7042fa6987..f8b4ef3ac7c109 100644 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -90,6 +90,7 @@ from contextlib import contextmanager from rlcompleter import Completer from types import CodeType +from warnings import deprecated class Restart(Exception): @@ -418,6 +419,16 @@ def setup(self, f, tb): ] self.rcLines = [] + @property + @deprecated('Use curframe.f_locals instead') + def curframe_locals(self): + return self.curframe.f_locals + + @curframe_locals.setter + @deprecated('Use curframe.f_locals instead') + def curframe_locals(self, value): + pass + # Override Bdb methods def user_call(self, frame, argument_list): From 6741706e591f47ad16b1d344460557532acffa88 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Thu, 24 Oct 2024 22:13:09 -0400 Subject: [PATCH 2/6] Add curframe_locals to test_pyclbr --- Lib/test/test_pyclbr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py index 4bf0576586cca5..6211ca1a40892c 100644 --- a/Lib/test/test_pyclbr.py +++ b/Lib/test/test_pyclbr.py @@ -234,7 +234,7 @@ def test_others(self): cm( 'pdb', # pyclbr does not handle elegantly `typing` or properties - ignore=('Union', '_ModuleTarget', '_ScriptTarget', '_ZipTarget'), + ignore=('Union', '_ModuleTarget', '_ScriptTarget', '_ZipTarget', 'curframe_locals'), ) cm('pydoc', ignore=('input', 'output',)) # properties From cc66f838750a5ac5ebb2bb2d08ea3ff08d354d10 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Sat, 23 Nov 2024 16:15:52 -0500 Subject: [PATCH 3/6] Apply suggestions from code review Co-authored-by: Alyssa Coghlan --- Lib/pdb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/pdb.py b/Lib/pdb.py index f8b4ef3ac7c109..c97942a1758284 100644 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -420,12 +420,12 @@ def setup(self, f, tb): self.rcLines = [] @property - @deprecated('Use curframe.f_locals instead') + @deprecated("The frame locals reference is no longer cached. Use 'curframe.f_locals' instead.") def curframe_locals(self): return self.curframe.f_locals @curframe_locals.setter - @deprecated('Use curframe.f_locals instead') + @deprecated("Setting 'curframe_locals' no longer has any effect. Update the contents of 'curframe.f_locals' instead.") def curframe_locals(self, value): pass From ddd76c96c1ec619bd9d5c99d6fe5c5492acbf672 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 23 Nov 2024 21:17:32 +0000 Subject: [PATCH 4/6] =?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/2024-11-23-21-17-28.gh-issue-124369.Z0hQFQ.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2024-11-23-21-17-28.gh-issue-124369.Z0hQFQ.rst diff --git a/Misc/NEWS.d/next/Library/2024-11-23-21-17-28.gh-issue-124369.Z0hQFQ.rst b/Misc/NEWS.d/next/Library/2024-11-23-21-17-28.gh-issue-124369.Z0hQFQ.rst new file mode 100644 index 00000000000000..31840da74a2dea --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-11-23-21-17-28.gh-issue-124369.Z0hQFQ.rst @@ -0,0 +1 @@ +Deprecate ``pdb.Pdb.curframe_locals`` From 295e29989c3572dad84763eb0ba0119487a71259 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Sat, 23 Nov 2024 16:22:12 -0500 Subject: [PATCH 5/6] Update whatsnew --- Doc/whatsnew/3.14.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index bc4ab6789e1676..2594be8393ecde 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -612,6 +612,12 @@ Deprecated write new code. The :mod:`subprocess` module is recommended instead. (Contributed by Victor Stinner in :gh:`120743`.) +* :mod:`pdb`: + The undocumented ``pdb.Pdb.curframe_locals`` is deprecated because with + PEP 667 we don't need to cache the locals anymore. Derived debuggers + should access ``pdb.Pdb.curframe.f_locals`` directly. + (Contributed by Tian Gao in :gh:`124369` and :gh:`125951`.) + * :mod:`symtable`: Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest. (Contributed by Bénédikt Tran in :gh:`119698`.) From 5678d104a88958d5d5bd30f3d0a658134480998b Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Sat, 8 Feb 2025 18:13:28 -0500 Subject: [PATCH 6/6] Update 3.14.rst --- Doc/whatsnew/3.14.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 2594be8393ecde..2ebe42ee447272 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -613,9 +613,11 @@ Deprecated (Contributed by Victor Stinner in :gh:`120743`.) * :mod:`pdb`: - The undocumented ``pdb.Pdb.curframe_locals`` is deprecated because with - PEP 667 we don't need to cache the locals anymore. Derived debuggers - should access ``pdb.Pdb.curframe.f_locals`` directly. + The undocumented ``pdb.Pdb.curframe_locals`` attribtue is now a deprecated + read-only property. The low overhead dynamic frame locals access added in + Python 3.13 by PEP 667 means the frame locals cache reference previously + stored in this attribute is no longer needed. Derived debuggers should access + ``pdb.Pdb.curframe.f_locals`` directly in Python 3.13 and later versions. (Contributed by Tian Gao in :gh:`124369` and :gh:`125951`.) * :mod:`symtable`: