diff --git a/mitogen/core.py b/mitogen/core.py index db3d4be6..af7bf28e 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -682,27 +682,25 @@ class Importer(object): _tls.running = True try: - pkgname, dot, _ = fullname.rpartition('.') - _vv and IOLOG.debug('%r.find_module(%r)', self, fullname) - suffix = fullname[len(pkgname+dot):] - if suffix not in self._present.get(pkgname, (suffix,)): - _v and LOG.debug('%r: master doesn\'t know %r', self, fullname) - return None - - pkg = sys.modules.get(pkgname) - if pkg and getattr(pkg, '__loader__', None) is not self: - _vv and IOLOG.debug( - '%r: %r is submodule of a package we did not load', - self, fullname - ) - return None - + _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: + LOG.debug('%r: %r is submodule of a package we did not load', + self, fullname) + return None + + suffix = fullname[len(pkgname+dot):] + if pkgname and suffix not in self._present.get(pkgname, ()): + _v and LOG.debug('%r: master doesn\'t know %r', self, fullname) + return None + try: self.builtin_find_module(fullname) _vv and IOLOG.debug('%r: %r is available locally', diff --git a/mitogen/master.py b/mitogen/master.py index 25bf8e83..46b1e84b 100644 --- a/mitogen/master.py +++ b/mitogen/master.py @@ -471,7 +471,7 @@ class ModuleFinder(object): for name in maybe_names if sys.modules.get(name) is not None and not is_stdlib_name(name) - and 'six.moves' not in name # TODO: crap + and u'six.moves' not in name # TODO: crap ) ))