-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
On Linux, sys.executable
is determined using argv[0]
, and trying to find that in the PATH
. This presumes that the Python interpreter has been started by a shell that interprets PATH
in the canonical way. There is no guarantee that this happens at all, so sys.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
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error