[Python-Dev] Created branch for PEP 302 phase 2 work (in C)

Phillip J. Eby pje at telecommunity.com
Tue Oct 3 03:04:31 CEST 2006


At 08:21 PM 10/2/2006 -0400, A.M. Kuchling wrote:
>On Mon, Oct 02, 2006 at 11:27:07PM +0100, Paul Moore wrote:
> > Yes, I'm quite surprised at how much has appeared in pkgutil. The
> > "what's new" entry is very terse, and the module documentation itself
> > hasn't been updated to mention the new stuff.
>
>These two things are related, of course; I couldn't figure out which
>bits of pkgutil.py are intended to be publicly used and which weren't.
>There's an __all__ in the module, but some things such as read_code()
>don't look like they're intended for external use.

The __all__ listing is correct; I intended to expose read_code() for the 
benefit of other importer implementations and Python utilities.  Over the 
years, I've found myself writing the equivalent of read_code() several 
times, so it seemed to me to make sense to expose it as a utility function, 
since it already needed to be there for the ImpLoader class to work.

In general, the idea behind the additions to pkgutil was to make life 
easier for people doing import-related operations, by being a Python 
reference implementation of commonly-reinvented parts of the import 
process.  The '-m' machinery in 2.5 had a bunch of this stuff in it, and so 
did setuptools, so I yanked the code from both and refactored it to allow 
reuse by both, then fleshed it out to support all the optional PEP 302 
loader protocols, and additional protocols needed to support tools like 
pydoc being able to run against arbitrary importers (esp. zip files).



More information about the Python-Dev mailing list