8000 Provide curframe_locals for backward compatibility but deprecate it (… · python/cpython@29f8a67 · GitHub
[go: up one dir, main page]

Skip to content

Commit 29f8a67

Browse files
Provide curframe_locals for backward compatibility but deprecate it (#125951)
1 parent c1f352b commit 29f8a67

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,14 @@ Deprecated
932932
write new code. The :mod:`subprocess` module is recommended instead.
933933
(Contributed by Victor Stinner in :gh:`120743`.)
934934

935+
* :mod:`pdb`:
936+
The undocumented ``pdb.Pdb.curframe_locals`` attribtue is now a deprecated
937+
read-only property. The low overhead dynamic frame locals access added in
938+
Python 3.13 by PEP 667 means the frame locals cache reference previously
939+
stored in this attribute is no longer needed. Derived debuggers should access
8000 940+
``pdb.Pdb.curframe.f_locals`` directly in Python 3.13 and later versions.
941+
(Contributed by Tian Gao in :gh:`124369` and :gh:`125951`.)
942+
935943
* :mod:`symtable`:
936944
Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest.
937945
(Contributed by Bénédikt Tran in :gh:`119698`.)

Lib/pdb.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
from contextlib import contextmanager
9191
from rlcompleter import Completer
9292
from types import CodeType
93+
from warnings import deprecated
9394

9495

9596
class Restart(Exception):
@@ -421,6 +422,16 @@ def setup(self, f, tb):
421422
]
422423
self.rcLines = []
423424

425+
@property
426+
@deprecated("The frame locals reference is no longer cached. Use 'curframe.f_locals' instead.")
427+
def curframe_locals(self):
428+
return self.curframe.f_locals
429+
430+
@curframe_locals.setter
431+
@deprecated("Setting 'curframe_locals' no longer has any effect. Update the contents of 'curframe.f_locals' instead.")
432+
def curframe_locals(self, value):
433+
pass
434+
424435
# Override Bdb methods
425436

426437
def user_call(self, frame, argument_list):

Lib/test/test_pyclbr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_others(self):
226226
cm(
227227
'pdb',
228228
# pyclbr does not handle elegantly `typing` or properties
229-
ignore=('Union', '_ModuleTarget', '_ScriptTarget', '_ZipTarget'),
229+
ignore=('Union', '_ModuleTarget', '_ScriptTarget', '_ZipTarget', 'curframe_locals'),
230230
)
231231
cm('pydoc', ignore=('input', 'output',)) # properties
232232

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate ``pdb.Pdb.curframe_locals``

0 commit comments

Comments
 (0)
0