core: reordered find_module() test was broken (again)

e81b3bd0652b5eb125eb224ceca281b9d540dd5e

The whitelist check must happen /after/ the other checks, otherwise we
unconditionally retunr self for crap like 'ansible.module_utils.json'.
pull/295/head
David Wilson 6 years ago
parent 24ecfb3b13
commit a52064a24f

@ -683,12 +683,6 @@ class Importer(object):
_tls.running = True
try:
_v and LOG.debug('%r.find_module(%r)', self, fullname)
# #114: explicitly whitelisted prefixes override any
# system-installed package.
if self.whitelist != ['']:
if any(fullname.startswith(s) for s in self.whitelist):
return self
pkgname, dot, _ = fullname.rpartition('.')
pkg = sys.modules.get(pkgname)
if pkgname and getattr(pkg, '__loader__', None) is not self:
@ -701,6 +695,12 @@ class Importer(object):
_v and LOG.debug('%r: master doesn\'t know %r', self, fullname)
return None
# #114: explicitly whitelisted prefixes override any
# system-installed package.
if self.whitelist != ['']:
if any(fullname.startswith(s) for s in self.whitelist):
return self
try:
self.builtin_find_module(fullname)
_vv and IOLOG.debug('%r: %r is available locally',

Loading…
Cancel
Save