[New-bugs-announce] [issue21211] pkgutil.find_loader() raises ImportError instead of returning None

Eric Snow report at bugs.python.org
Mon Apr 14 03:48:18 CEST 2014


New submission from Eric Snow:

In 3987667bf98f pkgutil.find_loader() switched from using pkgutil.iter_importers() to importlib.find_module().  importlib.find_module() checks the module's __loader__ (and raises ImportError when invalid) whereas iter_importers() does no such check.  In 3.4 pkgutil.find_loader() switched over to importlib.util.find_spec(), but the same issue remains.

The documentation (and the previous behavior) implies that the ImportError case coming out of find_spec() should result in pkgutil.find_loader() returning None rather than propagating the ImportError.  However, it may make more sense to do an explicit check for module.__spec__ before calling find_spec().

----------
components: Library (Lib)
keywords: 3.3regression
messages: 216047
nosy: brett.cannon, eric.snow, ncoghlan
priority: high
severity: normal
stage: test needed
status: open
title: pkgutil.find_loader() raises ImportError instead of returning None
type: behavior
versions: Python 3.3, Python 3.4, Python 3.5

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


More information about the New-bugs-announce mailing list