Prefer Python 3 over Python 2

When both versions are available, we prefer Python 3 over Python 2:
 - faster startup (no monkey-patching from python-future);
 - better Windows support (e.g. temporary paths are not returned in all
   lowercase);
 - Python 2 support will eventually be dropped.
This commit is contained in:
micbou 2016-10-24 04:41:36 +02:00
parent 0cc761fe00
commit b3e6bad6b1
No known key found for this signature in database
GPG Key ID: C7E8FD1F3BDA1E05

View File

@ -28,26 +28,29 @@ let s:cursor_moved = 0
let s:previous_allowed_buffer_number = 0 let s:previous_allowed_buffer_number = 0
function! s:UsingPython2() " When both versions are available, we prefer Python 3 over Python 2:
" I'm willing to bet quite a bit that sooner or later, somebody will ask us to " - faster startup (no monkey-patching from python-future);
" make it configurable which version of Python we use. " - better Windows support (e.g. temporary paths are not returned in all
if has('python') " lowercase);
" - Python 2 support will eventually be dropped.
function! s:UsingPython3()
if has('python3')
return 1 return 1
endif endif
return 0 return 0
endfunction endfunction
let s:using_python2 = s:UsingPython2() let s:using_python3 = s:UsingPython3()
let s:python_until_eof = s:using_python2 ? "python << EOF" : "python3 << EOF" let s:python_until_eof = s:using_python3 ? "python3 << EOF" : "python << EOF"
let s:python_command = s:using_python2 ? "py " : "py3 " let s:python_command = s:using_python3 ? "py3 " : "py "
function! s:Pyeval( eval_string ) function! s:Pyeval( eval_string )
if s:using_python2 if s:using_python3
return pyeval( a:eval_string ) return py3eval( a:eval_string )
endif endif
return py3eval( a:eval_string ) return pyeval( a:eval_string )
endfunction endfunction