[3.12] Clarifying nonlocal doc: SyntaxError is raised if nearest enclosing scope is global (GH-114009) (#118128)

Clarifying nonlocal doc: SyntaxError is raised if nearest enclosing scope is global (GH-114009)
(cherry picked from commit 1558d99316)

Co-authored-by: Quazi Irfan <quazirfan@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-04-21 03:50:01 +02:00 committed by GitHub
parent 23192aba20
commit 4d85f0ae76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -139,8 +139,9 @@ namespace. Names are resolved in the top-level namespace by searching the
global namespace, i.e. the namespace of the module containing the code block, global namespace, i.e. the namespace of the module containing the code block,
and the builtins namespace, the namespace of the module :mod:`builtins`. The and the builtins namespace, the namespace of the module :mod:`builtins`. The
global namespace is searched first. If the names are not found there, the global namespace is searched first. If the names are not found there, the
builtins namespace is searched. The :keyword:`!global` statement must precede builtins namespace is searched next. If the names are also not found in the
all uses of the listed names. builtins namespace, new variables are created in the global namespace.
The global statement must precede all uses of the listed names.
The :keyword:`global` statement has the same scope as a name binding operation The :keyword:`global` statement has the same scope as a name binding operation
in the same block. If the nearest enclosing scope for a free variable contains in the same block. If the nearest enclosing scope for a free variable contains