pyxversion: fix logic error #10759

Do not incorrectly prefer python2 if python3 is working.
fixes #10758
This commit is contained in:
Björn Linse
2019-08-14 22:36:43 +02:00
committed by Justin M. Keyes
parent ebcb9adcc4
commit 48b43352b0
3 changed files with 8 additions and 10 deletions

View File

@@ -13640,10 +13640,6 @@ static void f_pumvisible(typval_T *argvars, typval_T *rettv, FunPtr fptr)
*/
static void f_pyeval(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
if (p_pyx == 0) {
p_pyx = 2;
}
script_host_eval("python", argvars, rettv);
}
@@ -13652,10 +13648,6 @@ static void f_pyeval(typval_T *argvars, typval_T *rettv, FunPtr fptr)
*/
static void f_py3eval(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
if (p_pyx == 0) {
p_pyx = 3;
}
script_host_eval("python3", argvars, rettv);
}

View File

@@ -2830,9 +2830,9 @@ void ex_options(exarg_T *eap)
void init_pyxversion(void)
{
if (p_pyx == 0) {
if (!eval_has_provider("python3")) {
if (eval_has_provider("python3")) {
p_pyx = 3;
} else if (!eval_has_provider("python")) {
} else if (eval_has_provider("python")) {
p_pyx = 2;
}
}

View File

@@ -90,6 +90,12 @@ describe('python3 provider', function()
eq({1, 2, {['key'] = 'val'}}, eval([[py3eval('[1, 2, {"key": "val"}]')]]))
end)
it('pyxeval #10758', function()
eq(0, eval([[&pyxversion]]))
eq(3, eval([[pyxeval('sys.version_info[:3][0]')]]))
eq(3, eval([[&pyxversion]]))
end)
it('RPC call to expand("<afile>") during BufDelete #5245 #5617', function()
source([=[
python3 << EOF