[Bug] Python sys.executable command returns Vim path, not Pythons

324 views
Skip to first unread message

Stanislav Golovanov

unread,
Oct 11, 2013, 11:29:15 AM10/11/13
to vim...@googlegroups.com
Hello. I've stumbled on a problem that sys.executable python command inside Vim returns a Vim path, when it should return a Python path. Simple test case:

:py import sys
:py print sys.executable
C:\Program Files (x86)\Vim\vim74\gvim.exe

Should be:
C:\Python27\python.exe

vim --version: http://pastie.org/8395257

Nikolay Pavlov

unread,
Oct 11, 2013, 1:29:07 PM10/11/13
to vim...@googlegroups.com


On Oct 11, 2013 9:18 PM, "Stanislav Golovanov" <stgol...@gmail.com> wrote:
>
> Hello. I've stumbled on a problem that sys.executable python command inside Vim returns a Vim path, when it should return a Python path. Simple test case:
>
> :py import sys
> :py print sys.executable
> C:\Program Files (x86)\Vim\vim74\gvim.exe
>
> Should be:
> C:\Python27\python.exe

What makes you think so? File python.exe is not used by vim. You may remove it completely leaving relevant DLL library and vim will continue to work with +python and so will be plugins written in python. Why should output of sys.executable change if you remove irrelevant python.exe?

> vim --version: http://pastie.org/8395257
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Stanislav Golovanov

unread,
Oct 11, 2013, 2:21:59 PM10/11/13
to vim...@googlegroups.com
пятница, 11 октября 2013 г., 21:29:07 UTC+4 пользователь ZyX написал:
I've got your point. But since python manual (http://docs.python.org/2.7/library/sys.html?highlight=sys.executable#sys.executable) says it should return a path to used interpreter or return None if it's unable to retrieve it. Is Vim counts as an interpreter for Python (which is strange)? And whats the point to return a path to vim since it cant be used as a python interpreter?

There is a issue in YouCompleteMe plugin that references this: https://github.com/Valloric/YouCompleteMe/issues/581

Val Markovic

unread,
Oct 11, 2013, 3:35:58 PM10/11/13
to vim...@googlegroups.com
> What makes you think so? File python.exe is not used by vim. You may remove it completely leaving relevant DLL library and vim will continue to work with +python and so will be plugins written in python. Why should output of sys.executable change if you remove irrelevant python.exe?

Don't forget that ":py print sys.executable" will return the actual path to the Python interpreter (something like /usr/bin/python) on all Unix machines when run from Vim, but will return a path to Vim on Windows.

At the very least, the output of sys.executable in Vim should be consistent across platforms. It should either always return the path to Vim or to Python. I'd go with the path to Python since that's what the Python docs say it should return.

The API of Python system functions shouldn't change just because it's running inside Vim.

Nikolay Pavlov

unread,
Oct 11, 2013, 5:44:46 PM10/11/13
to vim...@googlegroups.com


On Oct 11, 2013 11:36 PM, "Val Markovic" <v...@markovic.io> wrote:
>
> > What makes you think so? File python.exe is not used by vim. You may remove it completely leaving relevant DLL library and vim will continue to work with +python and so will be plugins written in python. Why should output of sys.executable change if you remove irrelevant python.exe?
>
> Don't forget that ":py print sys.executable" will return the actual path to the Python interpreter (something like /usr/bin/python) on all Unix machines when run from Vim, but will return a path to Vim on Windows.
>
> At the very least, the output of sys.executable in Vim should be consistent across platforms. It should either always return the path to Vim or to Python. I'd go with the path to Python since that's what the Python docs say it should return.

I would go with path to vim since it is the actual user of the python library. But I agree that there should not be such inconsistency. I do not think though that this problem should be directed here and not to Python issue tracker: vim has nothing in if_py* files that may look like a source of this inconsistency. At least, I have never seen something like redefining sys.executable and do not remember any platform-specific code there.

Note: the python.exe itself is just the same user of the shared library as vim is. Since all sys staff can be found in the shared library and not in the library users (except for some explicit replacements like vim having a replacement for sys.stdout) I do not see why one of the users should be preferred over the other.

> The API of Python system functions shouldn't change just because it's running inside Vim.
>

Reply all
Reply to author
Forward
0 new messages