This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, serhiy.storchaka, terry.reedy, vstinner
Date 2021-02-27.10:33:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1614422012.06.0.895306636624.issue31030@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-02-27 10:33:32eryksunsetrecipients: + eryksun, terry.reedy, vstinner, serhiy.storchaka
2021-02-27 10:33:32eryksunsetmessageid: <1614422012.06.0.895306636624.issue31030@roundup.psfhosted.org>
2021-02-27 10:33:32eryksunlinkissue31030 messages
2021-02-27 10:33:31eryksuncreate