Message216066
Feel free to submit a patch.
On Fri, Apr 11, 2014, at 2:40, Dima Tisnek wrote:
>
> Dima Tisnek added the comment:
>
> I think consistency between Python versions is just as important as
> consistency between fd types.
>
> Here's my hack quickfix outline:
>
> fd = os.open(...)
> try:
> if not stat.S_ISREG(os.fstat(fd).st_mode):
> raise OSError(None, "Not a regular file", ...)
> f = os.fdopen(fd, ...)
> except EnvironmentError:
> os.close(fd)
>
> Can something like this be implemented in os.py
> There's already a check `if not isinstance(fd, int): raise ...`
>
> Granted we'd have to get fd type check exactly right.
Well, you just have check exactly what it's checking now, which seems to
be !S_ISDIR.
> fdopen should probably succeed for regular files, pipes, char devices,
> block device, ptry's ...
> fdopen should fail where underlying implementation fails, i.e.
> directories, sockets(?), epoll(?), timerfd(?)
>
> There's a list at http://en.wikipedia.org/wiki/File_descriptor
> I'm not sure about some types.
>
> P.S. I wish there was a way to rescue fd from FILE*, but nothing like
> that seems to exist...
Yes, this is one of the main problems.
>
> P.P.S. another option is to always use dup(), but that may break existing
> programs is they expect fd == fdopen(fd).fileno() |
|
Date |
User |
Action |
Args |
2014-04-14 04:05:29 | benjamin.peterson | set | recipients:
+ benjamin.peterson, python-dev, Dima.Tisnek |
2014-04-14 04:05:29 | benjamin.peterson | link | issue21191 messages |
2014-04-14 04:05:29 | benjamin.peterson | create | |
|