bpo-16781: In 'exec' doc, add 'nonlocal' to 'yield' and 'return' (GH-… · python/cpython@920bf6a (original) (raw)

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