Issue #17099: Have importlib.find_loader() raise ValueError when

__loader__ is not set on a module. This brings the exception in line
with when __loader__ is None (which is equivalent to not having the
attribute defined).
This commit is contained in:
Brett Cannon 2013-03-13 11:09:08 -07:00
parent 542308eae7
commit 327992330e
4 changed files with 26 additions and 1 deletions

View file

@ -90,7 +90,7 @@ Functions
Find the loader for a module, optionally within the specified *path*. If the
module is in :attr:`sys.modules`, then ``sys.modules[name].__loader__`` is
returned (unless the loader would be ``None``, in which case
returned (unless the loader would be ``None`` or is not set, in which case
:exc:`ValueError` is raised). Otherwise a search using :attr:`sys.meta_path`
is done. ``None`` is returned if no loader is found.
@ -99,6 +99,12 @@ Functions
will need to import all parent packages of the submodule and use the correct
argument to *path*.
.. versionadded:: 3.3
.. versionchanged:: 3.4
If ``__loader__`` is not set, raise :exc:`ValueError`, just like when the
attribute is set to ``None``.
.. function:: invalidate_caches()
Invalidate the internal caches of finders stored at