]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-16781: In 'exec' doc, add 'nonlocal' to 'yield' and 'return' (GH-2446)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 7 Feb 2021 05:38:54 +0000 (21:38 -0800)
committerGitHub <noreply@github.com>
Sun, 7 Feb 2021 05:38:54 +0000 (21:38 -0800)
These 3 statements cannot be used at module scope -- nor in exec with one namespace.
(cherry picked from commit 0ec57e25c918b859b9f8d464e34e0ac859c2f8b3)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Doc/library/functions.rst

index 5a039f7a9476ff807a438a0fa52a6b21e1d28aaf..9d67d80789fc983ca7bd50b967cf11f70c0710c5 100644 (file)
@@ -509,7 +509,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``.