Skip to content

Commit 4d85f0a

Browse files
miss-islingtonquazi-irfanJelleZijlstra
authored
[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 1558d99) Co-authored-by: Quazi Irfan <[email protected]> Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent 23192ab commit 4d85f0a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Doc/reference/executionmodel.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ namespace. Names are resolved in the top-level namespace by searching the
139139
global namespace, i.e. the namespace of the module containing the code block,
140140
and the builtins namespace, the namespace of the module :mod:`builtins`. The
141141
global namespace is searched first. If the names are not found there, the
142-
builtins namespace is searched. The :keyword:`!global` statement must precede
143-
all uses of the listed names.
142+
builtins namespace is searched next. If the names are also not found in the
143+
builtins namespace, new variables are created in the global namespace.
144+
The global statement must precede all uses of the listed names.
144145

145146
The :keyword:`global` statement has the same scope as a name binding operation
146147
in the same block. If the nearest enclosing scope for a free variable contains

0 commit comments

Comments
 (0)