Title: pkgutil.iter_importers() includes an ImpImporter
Type: Stage:
Components: Documentation Versions: Python 3.3, Python 2.7
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Arfrever, Ronan.Lamy, chris.jerdonek, docs@python
Priority: normal Keywords: easy

Created on 2012-07-08 21:13 by chris.jerdonek, last changed 2012-07-15 17:25 by chris.jerdonek. This issue is now closed.

Messages (4)
msg165035 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-07-08 21:12
I'm not sure if this should be fixed in the code or in the documentation, but the pkgutil.iter_importers() documentation says that pkgutil.iter_importers(name) should yield the "importers for sys.meta_path, sys.path, and Python’s “classic” import machinery, in that order" when name does not include a ".":

However, the function appends a "non-classic" pkgutil.ImpImporter at the end of all that:

Python 3.3.0b1 (default:5d43154d68a8, Jul  8 2012, 13:54:45) 
[GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.58)] on darwin
>>> from pkgutil import iter_importers
>>> list(iter_importers())[-1]
<pkgutil.ImpImporter object at 0x1035fa840>
msg165095 - (view) Author: Ronan Lamy (Ronan.Lamy) * Date: 2012-07-09 16:30
AFAICT, the intent of this function was to help provide a fully PEP-302 compliant import process wrapping the builtin C-implemented import mechanism. Nowadays, I believe that iterating over sys.meta_path should probably be enough.
msg165099 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-07-09 17:44
Marking this a documentation issue because the same behavior is also present in 2.7:

Python 2.7.3 (default, Apr 19 2012, 00:55:09) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
>>> from pkgutil import iter_importers
>>> list(iter_importers())[-1]
<pkgutil.ImpImporter instance at 0x10517b710>
msg165539 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-07-15 17:25
Closing as this is no longer an issue after Nick's pkgutil changes documented in issue 15343.
Date User Action Args
2012-07-15 17:25:16chris.jerdoneksetstatus: open -> closed

messages: + msg165539
2012-07-09 17:44:01chris.jerdoneksetassignee: docs@python
components: + Documentation, - Library (Lib)
versions: + Python 2.7
keywords: + easy
nosy: + docs@python

messages: + msg165099
2012-07-09 16:30:42Ronan.Lamysetnosy: + Ronan.Lamy
messages: + msg165095
2012-07-09 13:16:45Arfreversetnosy: + Arfrever
2012-07-08 21:13:00chris.jerdonekcreate