Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 757df6e

Browse files
committed
Document the import semantics that if None is found in sys.modules for a module then ImportError is raised.
1 parent 4d75fc1 commit 757df6e

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Doc/reference/simple_stmts.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,9 @@ Once the name of the module is known (unless otherwise specified, the term
668668
"module" will refer to both packages and modules), searching
669669
for the module or package can begin. The first place checked is
670670
:data:`sys.modules`, the cache of all modules that have been imported
671-
previously. If the module is found there then it is used in step (2) of import.
671+
previously. If the module is found there then it is used in step (2) of import
672+
unless :keyword:`None` is found in :data:`sys.modules`, in which case
673+
:exc:`ImportError` is raised.
672674

673675
.. index::
674676
single: sys.meta_path

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ Build
174174
Documenation
175175
------------
176176

177+
- Document that importing a module that has None in sys.modules triggers an
178+
ImportError.
179+
177180
- Issue #6556: Fixed the Distutils configuration files location explanation
178181
for Windows.
179182

0 commit comments

Comments
 (0)