]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] Clarifying nonlocal doc: SyntaxError is raised if nearest enclosing scope...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 21 Apr 2024 01:50:01 +0000 (03:50 +0200)
committerGitHub <noreply@github.com>
Sun, 21 Apr 2024 01:50:01 +0000 (01:50 +0000)
Clarifying nonlocal doc: SyntaxError is raised if nearest enclosing scope is global (GH-114009)
(cherry picked from commit 1558d993166636f371c1003107ec979db6744f21)

Co-authored-by: Quazi Irfan <quazirfan@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Doc/reference/executionmodel.rst

index cea3a56ba5164477e67183a309e2baafbae14421..ed50faed6c940d789be516a2caa072069cc17cb3 100644 (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,
 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
-builtins namespace is searched.  The :keyword:`!global` statement must precede
-all uses of the listed names.
+builtins namespace is searched next. If the names are also not found in the
+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
 in the same block.  If the nearest enclosing scope for a free variable contains