Skip to content

Commit b05ee20

Browse files
miss-islingtonKit Dallege
andauthored
[3.14] gh-137337: Clarify import statement namespace binding (GH-144607) (GH-149369)
It is not always in the local namespace. (cherry picked from commit b8ebd07) Co-authored-by: Kit Dallege <xaum.io@gmail.com>
1 parent fc390bd commit b05ee20

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Doc/reference/simple_stmts.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,9 @@ The basic import statement (no :keyword:`from` clause) is executed in two
760760
steps:
761761

762762
#. find a module, loading and initializing it if necessary
763-
#. define a name or names in the local namespace for the scope where
764-
the :keyword:`import` statement occurs.
763+
#. define a name or names in the current namespace for the scope where
764+
the :keyword:`import` statement occurs, just as an assignment statement
765+
would (including :keyword:`global` and :keyword:`nonlocal` semantics).
765766

766767
When the statement contains multiple clauses (separated by
767768
commas) the two steps are carried out separately for each clause, just
@@ -806,7 +807,7 @@ The :keyword:`from` form uses a slightly more complex process:
806807
#. if not, attempt to import a submodule with that name and then
807808
check the imported module again for that attribute
808809
#. if the attribute is not found, :exc:`ImportError` is raised.
809-
#. otherwise, a reference to that value is stored in the local namespace,
810+
#. otherwise, a reference to that value is stored in the current namespace,
810811
using the name in the :keyword:`!as` clause if it is present,
811812
otherwise using the attribute name
812813

0 commit comments

Comments
 (0)