]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-16781: In 'exec' doc, add 'nonlocal' to 'yield' and 'return' (GH-2446)
authorTerry Jan Reedy <tjreedy@udel.edu>
Sun, 7 Feb 2021 05:28:50 +0000 (00:28 -0500)
committerGitHub <noreply@github.com>
Sun, 7 Feb 2021 05:28:50 +0000 (00:28 -0500)
These 3 statements cannot be used at module scope -- nor in exec with one namespace.

Doc/library/functions.rst

index 55dd3f03f929c7c56d35f53ee89ab6b2bdc1293b..e36a1695c2ad58aa6fd8b950074f581a8236d9ea 100644 (file)
@@ -526,7 +526,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``.