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, paul.moore, steve.dower, tim.golden, zach.ware
Date 2017-02-01.03:06:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1485918380.71.0.564330613462.issue29409@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-02-01 03:06:20eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower
2017-02-01 03:06:20eryksunsetmessageid: <1485918380.71.0.564330613462.issue29409@psf.upfronthosting.co.za>
2017-02-01 03:06:20eryksunlinkissue29409 messages
2017-02-01 03:06:19eryksuncreate