Message387775
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/someone/.local/bin/../bin/python3.10
In test/test_sys.py, assertEqual(os.path.abspath(sys.executable), sys.executable) fails. In test/test_venv.py, assertIn('home = %s' % path, data) and assertEqual(out.strip(), expected.encode()) both fail, respectively in test_defaults and test_prefixes.
In Windows, prior to Python 3.6, this can be a problem if Python is run via CreateProcessW using a non-normalized path in lpApplicationName (rare, but possible) instead of letting the system search for the executable in lpCommandLine. For example:
>>> cmd = 'python -c "import sys; print(sys.executable)"'
>>> exe = r'C:\Program Files\Python35\..\Python35\python.exe'
>>> subprocess.call(cmd, executable=exe)
C:\Program Files\Python35\..\Python35\python.exe
0
It's no longer an issue in Windows with Python 3.6 and above. When getting the program path while initializing, the GetModuleFileNameW(NULL, ..) result gets canonicalized (e.g. via PathCchCanonicalizeEx). For example:
>>> exe = r'C:\Program Files\Python36\..\Python36\python.exe'
>>> subprocess.call(cmd, executable=exe)
C:\Program Files\Python36\python.exe
0 |
|
Date |
User |
Action |
Args |
2021-02-27 10:33:32 | eryksun | set | recipients:
+ eryksun, terry.reedy, vstinner, serhiy.storchaka |
2021-02-27 10:33:32 | eryksun | set | messageid: <1614422012.06.0.895306636624.issue31030@roundup.psfhosted.org> |
2021-02-27 10:33:32 | eryksun | link | issue31030 messages |
2021-02-27 10:33:31 | eryksun | create | |
|