Message286585
PEP 529 isn't implemented for io.FileIO, and I think it should be. If a UTF-8 path is passed to open(), it ends up calling C _open instead of decoding the path and calling C _wopen. Also, if a pathlike object is passed to io.FileIO, it calls PyUnicode_FSConverter on it, converting it to UTF-8 and then passing it to _open. For example:
>>> p = r'C:\Temp\αβψδ'
>>> os.path.exists(p)
True
>>> open(p.encode())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: b'C:\\Temp\\\xce\xb1\xce\xb2\xcf\x88\xce\xb4'
>>> io.FileIO(pathlib.Path(p))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: WindowsPath('C:/Temp/αβψδ')
The Windows implementation should mirror the POSIX implementation via PyUnicode_FSDecoder. |
|
Date |
User |
Action |
Args |
2017-02-01 03:06:20 | eryksun | set | recipients:
+ eryksun, paul.moore, tim.golden, zach.ware, steve.dower |
2017-02-01 03:06:20 | eryksun | set | messageid: <1485918380.71.0.564330613462.issue29409@psf.upfronthosting.co.za> |
2017-02-01 03:06:20 | eryksun | link | issue29409 messages |
2017-02-01 03:06:19 | eryksun | create | |
|