From 5e3212023660df60186e1cfac8d60ee4e3b026b5 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 27 Jun 2015 17:03:48 +0200 Subject: [PATCH] python: path_hook: properly implement PEP302 The path hook used to load the module already in the `find_module` hook. This caused different behaviour between Python 2.7 and 3.3, where the former would call the `VimModuleLoader`, while Python 3.3 appears to short-circuited this (because the module was loaded already). This patch will now only find the module, but not load it in the `find_module` hook. --- runtime/autoload/provider/script_host.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/runtime/autoload/provider/script_host.py b/runtime/autoload/provider/script_host.py index 9bdfc32ef0..10fd74816d 100644 --- a/runtime/autoload/provider/script_host.py +++ b/runtime/autoload/provider/script_host.py @@ -201,11 +201,10 @@ def path_hook(nvim): name = oldtail[:idx] tail = oldtail[idx+1:] fmr = imp.find_module(name, path) - module = imp.load_module(fullname[:-len(oldtail)] + name, *fmr) + module = imp.find_module(fullname[:-len(oldtail)] + name, *fmr) return _find_module(fullname, tail, module.__path__) else: - fmr = imp.find_module(fullname, path) - return imp.load_module(fullname, *fmr) + return imp.find_module(fullname, path) class VimModuleLoader(object): def __init__(self, module): @@ -215,7 +214,7 @@ def path_hook(nvim): # Check sys.modules, required for reload (see PEP302). if fullname in sys.modules: return sys.modules[fullname] - return self.module + return imp.load_module(fullname, *self.module) class VimPathFinder(object): @staticmethod