
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2017-02-01 03:06 byeryksun, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue_29409_01.patch | eryksun,2017-02-01 03:08 | review | ||
| Messages (6) | |||
|---|---|---|---|
| msg286585 -(view) | Author: Eryk Sun (eryksun)*![]() | Date: 2017-02-01 03:06 | |
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. | |||
| msg286998 -(view) | Author: Steve Dower (steve.dower)*![]() | Date: 2017-02-04 22:39 | |
Merging this in now, along with a few other patches. This is the test I'm adding, in case anyone spots any problems with it before I push (copied from the test for pure-ASCII bytes): @unittest.skipIf(sys.getfilesystemencoding() != 'utf-8', "test only works for utf-8 filesystems") def testUtf8BytesOpen(self): # Opening a UTF-8 bytes filename try: fn = TESTFN_UNICODE.encode("utf-8") except UnicodeEncodeError: self.skipTest('could not encode %r to utf-8' % TESTFN_UNICODE) f = self.FileIO(fn, "w") try: f.write(b"abc") f.close() with open(TESTFN_UNICODE, "rb") as f: self.assertEqual(f.read(), b"abc") finally: os.unlink(TESTFN_UNICODE) | |||
| msg287004 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2017-02-04 23:14 | |
New changeset0bf72810f8ea by Steve Dower in branch '3.6':Issue#29409: ImplementPEP 529 for io.FileIO (Patch by Eryk Sun)https://hg.python.org/cpython/rev/0bf72810f8eaNew changeseta5538734cc87 by Steve Dower in branch 'default':Merge issue#28164 and issue#29409https://hg.python.org/cpython/rev/a5538734cc87 | |||
| msg287006 -(view) | Author: Steve Dower (steve.dower)*![]() | Date: 2017-02-04 23:15 | |
Committed, but I'll leave this open for a bit in case anyone wants to comment on the commit. | |||
| msg287015 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2017-02-05 00:00 | |
New changesetfe7e868bad5bffaf863c80fa2bcc4e3bf87a413a by Steve Dower in branch 'master':Issue#29409: ImplementPEP 529 for io.FileIO (Patch by Eryk Sun)https://github.com/python/cpython/commit/fe7e868bad5bffaf863c80fa2bcc4e3bf87a413aNew changeset965f8d68a8dcc2ebb2480fe7e9121ac7efdee54e by Steve Dower in branch 'master':Merge issue#28164 and issue#29409https://github.com/python/cpython/commit/965f8d68a8dcc2ebb2480fe7e9121ac7efdee54e | |||
| msg287020 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2017-02-05 00:00 | |
New changesetfe7e868bad5bffaf863c80fa2bcc4e3bf87a413a by Steve Dower in branch '3.6':Issue#29409: ImplementPEP 529 for io.FileIO (Patch by Eryk Sun)https://github.com/python/cpython/commit/fe7e868bad5bffaf863c80fa2bcc4e3bf87a413a | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:42 | admin | set | github: 73595 |
| 2018-01-07 01:37:04 | steve.dower | set | status: open -> closed resolution: fixed stage: commit review -> resolved |
| 2017-02-05 00:00:34 | python-dev | set | messages: +msg287020 |
| 2017-02-05 00:00:31 | python-dev | set | messages: +msg287015 |
| 2017-02-04 23:15:27 | steve.dower | set | messages: +msg287006 stage: patch review -> commit review |
| 2017-02-04 23:14:35 | python-dev | set | nosy: +python-dev messages: +msg287004 |
| 2017-02-04 22:39:42 | steve.dower | set | assignee:steve.dower messages: +msg286998 stage: test needed -> patch review |
| 2017-02-01 03:08:32 | eryksun | set | stage: needs patch -> test needed |
| 2017-02-01 03:08:09 | eryksun | set | files: +issue_29409_01.patch keywords: +patch |
| 2017-02-01 03:06:20 | eryksun | create | |