[issue39379] sys.path[0] is already absolute path
STINNER Victor
report at bugs.python.org
Sat Feb 29 17:15:28 EST 2020
STINNER Victor <vstinner at python.org> added the comment:
> Is sys.path[0] always absolute, or is it just a side-effect of the site module (i.e. is it absolute even with -S)?
The absolute path is computed way before the site module is imported.
In Python 3.8, _PyPathConfig_ComputeSysPath0() computes sys.path[0] from sys.argv[0]. If the command line contains a script filename, this function uses realpath() on Unix and GetFullPathNameW() on Windows to get the absolute path. If -m is used, getcwd() is called.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39379>
_______________________________________
More information about the Python-bugs-list
mailing list