Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1870,14 +1870,19 @@ locals as builtin_locals

Return a dictionary containing the current scope's local variables.

NOTE: Whether or not updates to this dictionary will affect name lookups in
the local scope and vice-versa is *implementation dependent* and not
covered by any backwards compatibility guarantees.
In **non-optimized scopes** (e.g., module, class, `exec()`/`eval()`):
- Changes to the dictionary will affect the local variables, and vice versa.

In **optimized scopes** (e.g., functions, generators, coroutines):
- The dictionary is a snapshot of local variables at the time of the call.
- Changes to the dictionary do not affect local variables, and changes to local variables are not reflected in the dictionary.

NOTE: Behavior may vary by implementation, and changes to the dictionary in optimized scopes will not be reflected in local variables.
Comment on lines +1876 to +1880
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, didn't PEP-667 fix this? This behavior applies to <3.13.

[clinic start generated code]*/

static PyObject *
builtin_locals_impl(PyObject *module)
/*[clinic end generated code: output=b46c94015ce11448 input=7874018d478d5c4b]*/
/*[clinic end generated code: output=b46c94015ce11448 input=c673cc693bc4ed02]*/
{
return _PyEval_GetFrameLocals();
}
Expand Down
13 changes: 9 additions & 4 deletions Python/clinic/bltinmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading