Eryk Sun added the comment:
> If it was the tests, they seem to have been fixed elsewhere.
The cited tests haven't been changed to work with non-normalized
sys.executable, sys.prefix, etc. But it's not common to run the test suite with
a non-normalized path such as "Lib/../build/python".
>
Terry J. Reedy added the comment:
This issue was opened with 2 related facts of 2017:
a) sys.executable is not normalized
b) as a result, two tests failed
Serhiy then said "I don't know what is wrong: the value of sys.executable or
the test." If it was the tests, they seem to have been fixed
Eryk Sun added the comment:
In Python 3.10 in POSIX, it's still the case that executable, prefix,
exec_prefix, base_prefix, and base_exec_prefix in the sys module do not get
normalized. For example, in Linux:
$ .local/bin/../bin/python3.10 -c "import sys; print(sys.executable)"
/home
Eryk Sun added the comment:
Terry, the Windows implementation calls GetModuleFileNameW to get the
executable's fully-qualified path from the loader. However, depending on how
Python is started, this could be a \\?\ path, which leads to a bug in the
startup code that determines the prefix path
Terry J. Reedy added the comment:
On Windows, sys.executable is normalized before or during startup.
C:\Programs\Python36>Lib\..\python -m test test_sys prints
test_executable (__main__.SysModuleTest) ... ok
C:\Programs\Python36>Lib\..\python -c "import sys; print(sys.executable)"
C:\Programs\
STINNER Victor added the comment:
Technically, /home/serhiy/py/cpython/Lib/../python is absolute and is a valid
path. I'm not sure that it's possible to normalize sys.executable early in the
Python initialization.
If we modify the site module to normalize sys.executable, it would mean that
sy
Serhiy Storchaka added the comment:
test_venv fails for the same cause.
$ Lib/../python -m test -m test_defaults test_venv
Run tests sequentially
0:00:00 load avg: 0.31 [1/1] test_venv
test test_venv failed -- Traceback (most recent call last):
File "/home/serhiy/py/cpython/Lib/test/test_venv.
New submission from Serhiy Storchaka:
test_executable in Lib/test/test_sys.py tests that sys.executable is absolute.
But this test is too strong, it fails if sys.executable is not normalized.
$ Lib/../python -m test test_sys
Run tests sequentially
0:00:00 load avg: 0.39 [1/1] test_sys
test test