mirror of
https://github.com/neovim/neovim.git
synced 2025-12-17 11:55:34 +00: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:
committed by
Justin M. Keyes
parent
e085cacba4
commit
31536ae003
@@ -202,7 +202,8 @@ function! s:version_info(python) abort
|
|||||||
|
|
||||||
let nvim_path = s:trim(s:system([
|
let nvim_path = s:trim(s:system([
|
||||||
\ a:python, '-c',
|
\ a:python, '-c',
|
||||||
\ 'import sys; sys.path.remove(""); ' .
|
\ 'import sys; ' .
|
||||||
|
\ 'sys.path = list(filter(lambda x: x != "", sys.path)); ' .
|
||||||
\ 'import neovim; print(neovim.__file__)']))
|
\ 'import neovim; print(neovim.__file__)']))
|
||||||
if s:shell_error || empty(nvim_path)
|
if s:shell_error || empty(nvim_path)
|
||||||
return [python_version, 'unable to load neovim Python module', pypi_version,
|
return [python_version, 'unable to load neovim Python module', pypi_version,
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ function! provider#pythonx#Require(host) abort
|
|||||||
|
|
||||||
" Python host arguments
|
" Python host arguments
|
||||||
let prog = (ver == '2' ? provider#python#Prog() : provider#python3#Prog())
|
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
|
" Collect registered Python plugins into args
|
||||||
let python_plugins = remote#host#PluginsForHost(a:host.name)
|
let python_plugins = remote#host#PluginsForHost(a:host.name)
|
||||||
@@ -66,7 +67,7 @@ endfunction
|
|||||||
function! s:import_module(prog, module) abort
|
function! s:import_module(prog, module) abort
|
||||||
let prog_version = system([a:prog, '-c' , printf(
|
let prog_version = system([a:prog, '-c' , printf(
|
||||||
\ 'import sys; ' .
|
\ '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])); ' .
|
\ 'sys.stdout.write(str(sys.version_info[0]) + "." + str(sys.version_info[1])); ' .
|
||||||
\ 'import pkgutil; ' .
|
\ 'import pkgutil; ' .
|
||||||
\ 'exit(2*int(pkgutil.get_loader("%s") is None))',
|
\ 'exit(2*int(pkgutil.get_loader("%s") is None))',
|
||||||
|
|||||||
Reference in New Issue
Block a user