Skip to content

Commit 863eb71

Browse files
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 0ec57e2) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
1 parent 39aeb9f commit 863eb71

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Doc/library/functions.rst

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

0 commit comments

Comments
 (0)