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.

Author chris.jerdonek
Recipients chris.jerdonek
Date 2012-07-08.21:48:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1341784087.15.0.754005593473.issue15299@psf.upfronthosting.co.za>
In-reply-to
Content
The pkgutil.ImpImporter documentation says that if dirname is None, ImpImporter(dirname) should create a PEP 302 importer that searches the current sys.path, plus any modules that are frozen or built-in:

http://docs.python.org/dev/library/pkgutil.html#pkgutil.ImpImporter

However, the iter_modules() method of an ImpImporter instance doesn't search sys.path if dirname is None.  It returns a generator that always yields nothing.  For example--

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 ImpImporter
>>> importer = ImpImporter()
>>> list(importer.iter_modules())
[]

Strictly speaking, one could say the documentation only applies to the find_module() method since that's the only method covered by the PEP 302 API  However, iter_modules() is a public method.  So I think that either iter_modules() should be fixed, made private, or else the documentation clarified by saying that searching sys.path does not apply to iter_modules().

I'm pretty sure though that iter_modules() should be fixed.  This is because there are other functions in pkgutil that seem not to work because ImpImporter.iter_modules() behaves the way it does (specifically calling pkgutil.iter_modules() with path=None).
History
Date User Action Args
2012-07-08 21:48:07chris.jerdoneksetrecipients: + chris.jerdonek
2012-07-08 21:48:07chris.jerdoneksetmessageid: <1341784087.15.0.754005593473.issue15299@psf.upfronthosting.co.za>
2012-07-08 21:48:06chris.jerdoneklinkissue15299 messages
2012-07-08 21:48:05chris.jerdonekcreate