[issue30436] importlib.find_spec raises AttributeError/ModuleNotFoundError when parent is not a package/module

Brett Cannon report at bugs.python.org
Tue May 23 15:48:18 EDT 2017


Brett Cannon added the comment:

The key thing to think about is do you think find_spec("parent.module") is working with a single thing called "parent.module" or is it working with two separate things of "parent" and "module" which happens to be contained on "parent"? If you take the former view then you get the current semantics, but if you view it as the latter then you get the semantics you're suggesting, tkhyn.

My inclination is for the former semantics (i.e. think of it as a really long name for a specific module where it turns out the name is broken). If you look at it as find_spec(".submodule", package="parent") this also visually supports the idea that parent modules shouldn't trigger a None return. Finally, this would break any code that expects the current semantics.

So thanks for the bug report, but I'm going to close this as "not a bug".

----------
nosy: +brett.cannon, eric.snow, ncoghlan
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type:  -> behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30436>
_______________________________________


More information about the Python-bugs-list mailing list