Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.2k
Open
Description
Bug report
Bug description:
On Linux,sys.executable is determined usingargv[0], and trying to find that in thePATH. This presumes that the Python interpreter has been started by a shell that interpretsPATH in the canonical way. There is no guarantee that this happens at all, sosys.executable may point to something completely different, or is even the empty string.
As an example:
bash -c 'exec -a whatever python -c "import sys;print(sys.executable)"'should output the path of the Python executable, but simply outputs nothing.
Even worse, one can make Python output a wrong executable, as in
bash -c 'exec -a /usr/bin/python python -c "import sys;print(sys.executable)"'CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux