From 1cc37f32b819bc90be588bd01e2a6c9699b43d9f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 27 Jun 2015 16:59:13 +0200 Subject: [PATCH] python: VimPathFinder: use find_spec for Python 3.4 Fixes https://github.com/neovim/neovim/issues/2909 --- runtime/autoload/provider/script_host.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/runtime/autoload/provider/script_host.py b/runtime/autoload/provider/script_host.py index e0b9ee6012..c600cff234 100644 --- a/runtime/autoload/provider/script_host.py +++ b/runtime/autoload/provider/script_host.py @@ -17,6 +17,9 @@ IS_PYTHON3 = sys.version_info >= (3, 0) if IS_PYTHON3: basestring = str + if sys.version_info >= (3, 4): + from importlib.machinery import PathFinder + @neovim.plugin class ScriptHost(object): @@ -212,8 +215,9 @@ def path_hook(nvim): return self.module class VimPathFinder(object): - @classmethod - def find_module(cls, fullname, path=None): + @staticmethod + def find_module(fullname, path=None): + "Method for Python 2.7 and 3.3." try: return VimModuleLoader( _find_module(fullname, fullname, path or _get_paths())) @@ -224,6 +228,11 @@ def path_hook(nvim): def load_module(cls, fullname, path=None): return _find_module(fullname, fullname, path or _get_paths()) + @staticmethod + def find_spec(fullname, path=None, target=None): + "Method for Python 3.4+." + return PathFinder.find_spec(fullname, path or _get_paths(), target) + def hook(path): if path == nvim.VIM_SPECIAL_PATH: return VimPathFinder