This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: importlib no longer uses imp.NullImporter
Type: Stage:
Components: Documentation Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: barry, brett.cannon, eric.smith, ncoghlan
Priority: normal Keywords:

Created on 2012-07-27 18:36 by barry, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg166595 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2012-07-27 18:36
I think this is mostly just out of date documentation, but I want to get Brett's feedback.  The sys module has this to say about sys.path_importer_cache:

"A dictionary acting as a cache for finder objects. The keys are paths that have been passed to sys.path_hooks and the values are the finders that are found. If a path is a valid file system path but no explicit finder is found on sys.path_hooks then None is stored to represent the implicit default finder should be used. If the path is not an existing path then imp.NullImporter is set."

Notice that last sentence.  AFAICT, this is not true in importlib.  I can find no relevant reference to imp.NullImporter in _bootstrap.py.  Maybe we should just remove this from the documentation?  OTOH, there are a few tests that check semantics related to imp.NullImporter found in sys.path_importer_cache, so clearly there are API constraints.  See also runpy.py, which gives some semantics to finding this importer in the cache.

Any suggestions for better wording about imp.NullImporter and sys.path_importer_cache?  I'd like to add this to my rewritten import machinery docs, but I'm not exactly sure what to say about it.
msg166713 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2012-07-29 04:21
See the porting notes: http://docs.python.org/dev/whatsnew/3.3.html#porting-python-code

With the removal of the implicit default finder, the 3.3 semantics are that both None *and* imp.NullImporter mean "There is no importer for this path".
msg166838 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-07-30 00:11
On Jul 29, 2012 12:21 AM, "Nick Coghlan" <report@bugs.python.org> wrote:
>
>
> Nick Coghlan added the comment:
>
> See the porting notes:
http://docs.python.org/dev/whatsnew/3.3.html#porting-python-code
>
> With the removal of the implicit default finder, the 3.3 semantics are
that both None *and* imp.NullImporter mean "There is no importer for this
path".

What Nick said is true, but for docs it's too broad a statement. Since
nullimporter inherently never finds anything it acts like there is no
importer. But the new behaviour is the use of None to represent that which
is the official semantics now.

-brett

>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue15473>
> _______________________________________
msg167261 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-08-02 21:55
Did this get addressed in the final doc update?
msg167264 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2012-08-02 22:14
Barry covered it in a footnote
History
Date User Action Args
2022-04-11 14:57:33adminsetgithub: 59678
2012-08-03 13:12:28brett.cannonsetstatus: open -> closed
resolution: fixed
2012-08-02 22:14:09ncoghlansetmessages: + msg167264
2012-08-02 21:55:36brett.cannonsetmessages: + msg167261
2012-07-30 00:11:04brett.cannonsetmessages: + msg166838
2012-07-29 04:21:26ncoghlansetmessages: + msg166713
2012-07-27 18:36:56barrycreate