[Import-SIG] PEP 402: specification questions

PJ Eby pje at telecommunity.com
Wed Nov 9 18:24:26 CET 2011

On Wed, Nov 9, 2011 at 4:35 AM, "Martin v. Löwis" <martin at v.loewis.de>wrote:

> I'm trying to understand PEP 402, and have difficulties figuring
> out what exactly it says. I presume that the section "Specification"
> is intended to give the complete syntax and semantics of the
> proposed change to Python.
> A. In "Virtual Paths", it talks about obtaining importer objects
>   for each path item, and then calling get_subpath on it. In the
>   current implementation, not all sys.path entries correspond to
>   an importer object: so what's the impact (if any) on old-style
>   sys.path entries (i.e. regular directories)?

Sorry - that's meant to be the importer returned by pkgutil.get_importer();
it should probably be made clearer.  (IIUC, under the importlib version,
there is *always* an importer object, whether you obtain it via pkgutil or
some other means.)

  Or, if some "builtin" importer is implied: what is its semantics
>   of get_subpath for the builtin importer?

Those described in the rest of the PEP: i.e., if the subpath exists, return
it.  For a directory, that's os.path.isdir(os.path.join(base_path,

> B. "Specification" starts with "importing names containing at least
>   one .". That seems clear enough, however, I wonder whether
>   from zope import interface
>   is supported by the PEP (i.e. where zope.interface is a nested
>   package, yet the names in the import don't contain a dot at all).
>   I presume that the case is meant to be supported, but then I
>   wonder how precisely the mechanism described in the PEP is
>   triggered.

IIRC, "from zope import interface" does an import zope.interface
internally.  It does occur to me, however, that if it first imports zope
and tries to get an attribute of it, then that import would fail.  That
case should probably be addressed explicitly in the PEP.

I was under the impression, though, that you were wanting to do a revised
PEP 382 instead?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/import-sig/attachments/20111109/44e223a5/attachment.html>

More information about the Import-SIG mailing list