Message413272
MSYS2 has basically the same problem when the script is passed as a Windows path, except it uses "/c" for the "C:" drive instead of "/cygdrive/c".
# python3 -VV
Python 3.9.9 (main, Dec 28 2021, 11:05:23)
[GCC 11.2.0]
# echo $PWD
/proc
# python3 C:/Temp/test.py
python3: can't open file '/proc/C:/Temp/test.py': [Errno 2] No such file or directory
Windows paths in the command-line arguments appear to be passed without conversion:
# python3 -ic 1 C:/Temp/test.py
>>> import os
>>> open(f'/proc/{os.getpid()}/cmdline').read().split('\0')
['python3', '-ic', '1', 'C:/Temp/test.py', '']
They're generally supported:
>>> open('C:/Temp/test.py').read()
'import sys\nprint(sys.executable)\n\n'
>>> os.path.samefile('C:/Temp/test.py', '/c/Temp/test.py')
True
>>> os.path.abspath('C:/Temp/test.py')
'C:/Temp/test.py'
realpath() doesn't support them:
>>> os.path.realpath('C:/Temp/test.py')
'/:/Temp/test.py'
But the C API _Py_wrealpath() does:
>>> import ctypes
>>> path = (ctypes.c_wchar * 1000)()
>>> ctypes.pythonapi._Py_wrealpath('C:/Temp/test.py', path, 1000)
1484496
>>> path.value
'/c/Temp/test.py' |
|
Date |
User |
Action |
Args |
2022-02-14 23:41:25 | eryksun | set | recipients:
+ eryksun, paul.moore, eric.smith, tim.golden, zach.ware, steve.dower, mikekaganski |
2022-02-14 23:41:25 | eryksun | set | messageid: <1644882085.38.0.129689719261.issue46751@roundup.psfhosted.org> |
2022-02-14 23:41:25 | eryksun | link | issue46751 messages |
2022-02-14 23:41:25 | eryksun | create | |
|