aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsupermomonga <hi@supermomonga.com>2019-10-28 06:27:22 +0900
committerJustin M. Keyes <justinkz@gmail.com>2019-10-27 14:27:22 -0700
commit31536ae003c0bd0ee311fc97b26ded0db8b3fa34 (patch)
treeb8382a43ff635f54ba2863842270ea687b4940d4
parente085cacba4e98e476da157616591c24d97b402c7 (diff)
downloadrneovim-31536ae003c0bd0ee311fc97b26ded0db8b3fa34.tar.gz
rneovim-31536ae003c0bd0ee311fc97b26ded0db8b3fa34.tar.bz2
rneovim-31536ae003c0bd0ee311fc97b26ded0db8b3fa34.zip
provider/pythonx: don't assume CWD (empty string) is in path #11304
sys.path.remove("") raises ValueError if the item is missing. https://docs.python.org/3/library/functions.html#filter: > filter(function, iterable) is equivalent to the generator expression (item > for item in iterable if function(item)) fixes #11293
-rw-r--r--runtime/autoload/health/provider.vim3
-rw-r--r--runtime/autoload/provider/pythonx.vim5
2 files changed, 5 insertions, 3 deletions
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index c750a954fa..ad7a614ff5 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -202,7 +202,8 @@ function! s:version_info(python) abort
let nvim_path = s:trim(s:system([
\ a:python, '-c',
- \ 'import sys; sys.path.remove(""); ' .
+ \ 'import sys; ' .
+ \ 'sys.path = list(filter(lambda x: x != "", sys.path)); ' .
\ 'import neovim; print(neovim.__file__)']))
if s:shell_error || empty(nvim_path)
return [python_version, 'unable to load neovim Python module', pypi_version,
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index 6ce7165467..aec18c0508 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -10,7 +10,8 @@ function! provider#pythonx#Require(host) abort
" Python host arguments
let prog = (ver == '2' ? provider#python#Prog() : provider#python3#Prog())
- let args = [prog, '-c', 'import sys; sys.path.remove(""); import neovim; neovim.start_host()']
+ let args = [prog, '-c', 'import sys; sys.path = list(filter(lambda x: x != "", sys.path)); import neovim; neovim.start_host()']
+
" Collect registered Python plugins into args
let python_plugins = remote#host#PluginsForHost(a:host.name)
@@ -66,7 +67,7 @@ endfunction
function! s:import_module(prog, module) abort
let prog_version = system([a:prog, '-c' , printf(
\ 'import sys; ' .
- \ 'sys.path.remove(""); ' .
+ \ 'sys.path = list(filter(lambda x: x != "", sys.path)); ' .
\ 'sys.stdout.write(str(sys.version_info[0]) + "." + str(sys.version_info[1])); ' .
\ 'import pkgutil; ' .
\ 'exit(2*int(pkgutil.get_loader("%s") is None))',