Issue 15247: io.open() is inconsistent re os.open() (original) (raw)

Created on 2012-07-04 02:55 by apalala, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg164633 - (view) Author: Juancarlo Añez (apalala) * Date: 2012-07-04 02:55
>>> import io >>> d = io.open('.') Traceback (most recent call last): File "", line 1, in IsADirectoryError: [Errno 21] Is a directory: '.' >>> >>> import os >>> d = io.open(os.open('.',0)) >>> d <_io.TextIOWrapper name=3 mode='r' encoding='UTF-8'> >>>
msg164634 - (view) Author: Juancarlo Añez (apalala) * Date: 2012-07-04 02:56
io.open() clearly doesn't care about opening directories as long as they are passed as os.open() file descriptors. Quite unexpected!
msg164655 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-07-04 17:55
Good catch indeed.
msg164664 - (view) Author: Juancarlo Añez (apalala) * Date: 2012-07-04 23:00
Note that attempting subsequent operations on the returned object do raise IsADirectoryError. >>> import io >>> import os >>> d = io.open(os.open('.',0)) >>> d.read() Traceback (most recent call last): File "", line 1, in IsADirectoryError: [Errno 21] Is a directory >>>
msg164737 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-07-06 17:02
New changeset 9cf9527358a5 by Antoine Pitrou in branch '3.2': Issue #15247: FileIO now raises an error when given a file descriptor pointing to a directory. http://hg.python.org/cpython/rev/9cf9527358a5 New changeset 19bd61ed3b3b by Antoine Pitrou in branch 'default': Issue #15247: FileIO now raises an error when given a file descriptor pointing to a directory. http://hg.python.org/cpython/rev/19bd61ed3b3b New changeset d7040647d590 by Antoine Pitrou in branch '2.7': Issue #15247: FileIO now raises an error when given a file descriptor pointing to a directory. http://hg.python.org/cpython/rev/d7040647d590
msg164738 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-07-06 17:03
Thanks, the issue should be fixed now.
History
Date User Action Args
2022-04-11 14:57:32 admin set github: 59452
2012-07-06 17:03:35 pitrou set status: open -> closedresolution: fixedmessages: + stage: needs patch -> resolved
2012-07-06 17:02:32 python-dev set nosy: + python-devmessages: +
2012-07-06 16🔞04 davbo set nosy: + davbo
2012-07-04 23:00:02 apalala set messages: +
2012-07-04 22:35:44 Arfrever set nosy: + Arfrever
2012-07-04 17:55:22 pitrou set versions: + Python 3.2nosy: + pitroumessages: + components: + IOstage: needs patch
2012-07-04 02:56:47 apalala set messages: +
2012-07-04 02:55:08 apalala create