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.
This commit is contained in:
Daniel Hahler 2015-06-27 17:03:48 +02:00
parent ad6dfa6669
commit 5e32120236

View File

@ -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