bpo-30436: Raise ModuleNotFoundError for importlib.util.find_spec() when parent isn't a package (GH-1899)

Previously AttributeError was raised, but that's not very reflective of the fact that the requested module can't be found since the specified parent isn't actually a package.
This commit is contained in:
Milan Oberkirch 2017-06-15 07:34:50 +10:00 committed by Brett Cannon
parent 32fd874afe
commit 8c3f05e9f0
5 changed files with 24 additions and 4 deletions

View file

@ -1215,6 +1215,11 @@ an :term:`importer`.
.. versionadded:: 3.4
.. versionchanged:: 3.7
Raises :exc:`ModuleNotFoundError` instead of :exc:`AttributeError` if
**package** is in fact not a package (i.e. lacks a :attr:`__path__`
attribute).
.. function:: module_from_spec(spec)
Create a new module based on **spec** and