The documentation is pretty opaque or non-existent on other aspects of
importlib use, too.  If I enable warnings, I see this (and many more like
it).  I've read PEP 302 a couple times, read the code in importlib that
detects the warning and searched down several rabbit holes, only to come up

T:\Python36\lib\importlib\ ImportWarning: can't resolve
package from __spec__ or __package__, falling back on __name__ and __path__

My thoughts when I see it: "Ok.  So what does that mean?  Is it bad?  It
must be bad, otherwise I wouldn't get a warning.  How do I reconcile
__spec__ and __package__?  Which one is missing and/or incorrect?"

On Mon, Apr 16, 2018 at 9:36 AM, Paul Moore <> wrote:

> On 16 April 2018 at 17:22, Nick Coghlan <> wrote:
> > If we're not covering explicit __path__ manipulation anywhere, we
> > should definitely mention that possibility.
> >
> > does talk about it, but only in the context of scanning sys.path for
> > matching names, not in the context of building a package from an
> > arbitrary set of directory names.
> It's quite possible that we're not.
> > I'm not sure where we could put an explanation of some of the broader
> > implications of that fact, though - while __path__ manipulation is
> > usually fairly safe, we're always a little hesitant about encouraging
> > too many dynamic modifications to the import system state, since it
> > can sometimes have odd side effects based on whether imports happen
> > before or after that state is adjusted..
> One of the problems with PEP 302 was that there was no really good
> place in the documentation to put all the information that was present
> (certainly not in the version of the docs that was around when we
> wrote it). So a lot of the important details remained buried in PEP
> 302. Since then, a lot of the details ended up in the docs, mostly in
> the importlib sections, but I don't recall ever seeing anything about
> __path__ (and particularly not the nice summary you gave, "packages
> are ultimately just modules with a
> __path__ attribute that works like sys.path".
> Paul
> _______________________________________________
> Python-ideas mailing list
> Code of Conduct:
Python-ideas mailing list
Code of Conduct:

Reply via email to