Skip to content

gh-74929: PEP 667 general docs update #119201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Cleanup Sphinx lint errors
  • Loading branch information
ncoghlan committed May 20, 2024
commit 9ba869be9087520fdfc0ff615e8955bb9cdab974
19 changes: 10 additions & 9 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1063,14 +1063,15 @@ are always available. They are listed here in alphabetical order.
variable names as the keys, and their currently bound references as the
values.

At module scope, as well as when using ``exec()`` or ``eval()`` with a
single namespace, this function returns the same namespace as ``globals()``.
At module scope, as well as when using :func:`exec` or :func:`eval` with
a single namespace, this function returns the same namespace as
:func:`globals`.

At class scope, it returns the namespace that will be passed to the
metaclass constructor.

When using ``exec()`` or ``eval()`` with separate local and global
namespaces, it returns the local namespace passed in to the function call.
arguments, it returns the local namespace passed in to the function call.

In all of the above cases, each call to ``locals()`` in a given frame of
execution will return the *same* mapping object. Changes made through
Expand Down Expand Up @@ -1116,20 +1117,20 @@ are always available. They are listed here in alphabetical order.
returned dictionary with the results of subsequent calls to ``locals()``.

.. versionchanged:: 3.13
As part of :pep:`667`, calling `locals()` in a comprehension at module
or class scope (including via `exec` or `eval`) once more behaves as if
As part of :pep:`667`, calling ``locals()`` in a comprehension at module
or class scope (including via ``exec`` or ``eval``) once more behaves as if
the comprehension were running as an independent nested function (i.e.
the local variables from the containing scope are not included).

.. versionchanged:: 3.12
As part of :pep:`709`, calling `locals()` in a comprehension at module
or class scope (including via `exec` or `eval`) produces an independent
As part of :pep:`709`, calling ``locals()`` in a comprehension at module
or class scope (including via ``exec`` or ``eval``) produces an independent
snapshot of the containing scope with the comprehension iteration
variable(s) included.

.. versionchanged:: 3.12
As part of :pep:`709`, calling `locals()` in a comprehension as part of a
function, generator, or coroutine returns the same `locals()` reference
As part of :pep:`709`, calling ``locals()`` in a comprehension as part of a
function, generator, or coroutine returns the same ``locals()`` reference
as calls in the containing scope.

..
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/pdb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ The typical usage to inspect a crashed program is::
(Pdb)

.. versionchanged:: 3.13
The implementation of :pep:`667` means that name assignments made via `pdb`
The implementation of :pep:`667` means that name assignments made via ``pdb``
will consistently and directly affect the active scope, even when running
inside a function, generator, or coroutine.

Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Interpreter improvements:
Performance improvements are modest -- we expect to be improving this
over the next few releases.

* :pep:`667`: The `func:`locals` builtin now has defined semantics when mutating
* :pep:`667`: The :func:`locals` builtin now has defined semantics when mutating
the returned mapping. Python debuggers and similar tools may now more reliably
update local variables in optimised frames even during concurrent code
execution.
Expand Down