]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Provide curframe_locals for backward compatibility but deprecate it (#125951)
authorTian Gao <gaogaotiantian@hotmail.com>
Sat, 8 Feb 2025 23:35:28 +0000 (18:35 -0500)
committerGitHub <noreply@github.com>
Sat, 8 Feb 2025 23:35:28 +0000 (23:35 +0000)
Doc/whatsnew/3.14.rst
Lib/pdb.py
Lib/test/test_pyclbr.py
Misc/NEWS.d/next/Library/2024-11-23-21-17-28.gh-issue-124369.Z0hQFQ.rst [new file with mode: 0644]

index ba7e8b42ef1f249cac6074fb68c507c75bcd30e3..23b1f5f2e0c67c64490d13b53cc624120cfdf7c2 100644 (file)
@@ -932,6 +932,14 @@ 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`` 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`:
   Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest.
   (Contributed by Bénédikt Tran in :gh:`119698`.)
index beef74d792250bacd27f0b16d5920cef3cc3f769..4abf216b773780d45bc8ce6223144ae312b3c268 100644 (file)
@@ -90,6 +90,7 @@ import _colorize
 from contextlib import contextmanager
 from rlcompleter import Completer
 from types import CodeType
+from warnings import deprecated
 
 
 class Restart(Exception):
@@ -421,6 +422,16 @@ class Pdb(bdb.Bdb, cmd.Cmd):
             ]
             self.rcLines = []
 
+    @property
+    @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("Setting 'curframe_locals' no longer has any effect. Update the contents of 'curframe.f_locals' instead.")
+    def curframe_locals(self, value):
+        pass
+
     # Override Bdb methods
 
     def user_call(self, frame, argument_list):
index 25b313f6c25a4eabd0156727eb09e23d304abcbd..749109805677631cb05cc79ce39658480b118fad 100644 (file)
@@ -226,7 +226,7 @@ class PyclbrTest(TestCase):
         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
 
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 (file)
index 0000000..31840da
--- /dev/null
@@ -0,0 +1 @@
+Deprecate ``pdb.Pdb.curframe_locals``