From 8dcf7fe49c61c4394ea06de2e7110d4eba1032a3 Mon Sep 17 00:00:00 2001 From: Nick Coghlan Date: Thu, 2 Jan 2020 02:30:39 +1000 Subject: [PATCH] PEP 558: Fix mention of old locals() semantics (#1266) When updating the PEP to specify independent snapshots for locals() at function scope, I missed this reference to the old semantics that returned a direct reference to the dynamic internal snapshot. --- pep-0558.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pep-0558.rst b/pep-0558.rst index c3f3a357e..91a7214a2 100644 --- a/pep-0558.rst +++ b/pep-0558.rst @@ -290,11 +290,11 @@ defined ``locals()`` builtin, trace functions necessarily use the implementation dependent ``frame.f_locals`` interface, as a frame reference is what gets passed to hook implementations. -Instead of being a direct reference to the dynamic snapshot returned by -``locals()``, ``frame.f_locals`` will be updated to instead return a dedicated -proxy type (implemented as a private subclass of the existing -``types.MappingProxyType``) that has two internal attributes not exposed as -part of either the Python or public C API: +Instead of being a direct reference to the internal dynamic snapshot used to +populate the independent snapshots returned by ``locals()``, ``frame.f_locals`` +will be updated to instead return a dedicated proxy type (implemented as a +private subclass of the existing ``types.MappingProxyType``) that has two +internal attributes not exposed as part of the Python runtime API: * *mapping*: an implicitly updated snapshot of the function local variables and closure references, as well as any arbitrary items that have been set via @@ -302,6 +302,9 @@ part of either the Python or public C API: underlying frame * *frame*: the underlying frame that the snapshot is for +For backwards compatibility, the stored snapshot will continue to be made +available through the public ``PyEval_GetLocals()`` C API. + ``__getitem__`` operations on the proxy will read directly from the stored snapshot.