You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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().
On second thought, all modules (except __main__) must have both __spec__ and __loader__ set to their correct respective objects. So the current behavior is correct in that it exposes poorly formed modules.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: