From 8765f761c995c31c9bff6287d881f0e9b5d0cfc5 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 13 Feb 2018 15:47:38 +0545 Subject: [PATCH] importer: fix glaring bug in find_related() Overwriting 'fullname' variable caused basically nonsensical filtering. Result was including the module being searched in the list of dependencies, which was causing ModuleResponder to send it early, which was causing contexts to start importing the module before preloading of dependencies had completed. --- mitogen/master.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mitogen/master.py b/mitogen/master.py index 77b737fb..aa184a0e 100644 --- a/mitogen/master.py +++ b/mitogen/master.py @@ -401,7 +401,9 @@ class ModuleFinder(object): if level == -1: modnames = [modname, '%s.%s' % (fullname, modname)] else: - modnames = [self.resolve_relpath(fullname, level) + modname] + modnames = [ + '%s.%s' % (self.resolve_relpath(fullname, level), modname) + ] maybe_names.extend(modnames) maybe_names.extend( @@ -425,11 +427,12 @@ class ModuleFinder(object): found = set() while stack: - fullname = stack.pop(0) - fullnames = self.find_related_imports(fullname) - stack.extend(set(fullnames).difference(found, stack, [fullname])) - found.update(fullnames) + name = stack.pop(0) + names = self.find_related_imports(name) + stack.extend(set(names).difference(found, stack)) + found.update(names) + found.discard(fullname) return sorted(found)