diff options
author | Daniel Hahler <git@thequod.de> | 2015-06-27 16:59:13 +0200 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2015-07-09 13:43:29 +0200 |
commit | 1cc37f32b819bc90be588bd01e2a6c9699b43d9f (patch) | |
tree | 81dd813aba3fc082451709b87790b75fada1d0a4 | |
parent | ba2f7a9310bf3d3d0b028ad38e9724553e68c064 (diff) | |
download | rneovim-1cc37f32b819bc90be588bd01e2a6c9699b43d9f.tar.gz rneovim-1cc37f32b819bc90be588bd01e2a6c9699b43d9f.tar.bz2 rneovim-1cc37f32b819bc90be588bd01e2a6c9699b43d9f.zip |
python: VimPathFinder: use find_spec for Python 3.4
Fixes https://github.com/neovim/neovim/issues/2909
-rw-r--r-- | runtime/autoload/provider/script_host.py | 13 |
1 files 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 |