bpo-16781: In 'exec' doc, add 'nonlocal' to 'yield' and 'return' (GH-2446)

These 3 statements cannot be used at module scope -- nor in exec with one namespace.
(cherry picked from commit 0ec57e25c9)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
Miss Islington (bot) 2021-02-07 06:14:16 -08:00 committed by GitHub
parent 39aeb9ff90
commit 863eb7170b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -508,7 +508,8 @@ are always available. They are listed here in alphabetical order.
occurs). [#]_ If it is a code object, it is simply executed. In all cases,
the code that's executed is expected to be valid as file input (see the
section "File input" in the Reference Manual). Be aware that the
:keyword:`return` and :keyword:`yield` statements may not be used outside of
:keyword:`nonlocal`, :keyword:`yield`, and :keyword:`return`
statements may not be used outside of
function definitions even within the context of code passed to the
:func:`exec` function. The return value is ``None``.