Eryk Sun <eryk...@gmail.com> added the comment:
In 3.2, the default program name on non-Windows systems was changed to "python3" (see bpo-15020). In 3.5, the code was moved into Python/pylifecycle.c (see bpo-22869). Between 3.7 and 3.8, the initialization code was rewritten (see PEP 587). Currently it's set in config_init_program_name() in Python/initconfig.c. On POSIX systems, calculate_which() in Modules/getpath.c searches PATH to resolve the name if it has no path separator. For example: $ bash -c 'exec -a "" python -c "import sys; print(repr(sys.executable))"' '/home/someone/.local/bin/python3' The default "python3" program name isn't used if C argv[0] is non-empty, in which case calculate_which() may or may not find the given program name: $ bash -c 'exec -a "ls" python -c "import sys; print(repr(sys.executable))"' '/usr/bin/ls' $ bash -c 'exec -a "py" python -c "import sys; print(repr(sys.executable))"' '' In Windows, the default program name is "python", but this isn't relevant for sys.executable, which is based on GetModuleFileNameW(NULL, ...) instead. This is similar to using readlink("/proc/self/exe", ...) in Linux, except the loader in Windows, and thus GetModuleFileNameW(), does not resolve symlinks in the file path. ---------- nosy: +eryksun status: pending -> open _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue10835> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com