mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
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
This commit is contained in:
parent
e085cacba4
commit
31536ae003
@ -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,
|
||||
|
@ -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))',
|
||||
|
Loading…
Reference in New Issue
Block a user