msg66266 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2008-05-05 11:27 |
os.fstat doesn't accept a file object with a fileno() method. This can easily be fixed by using PyObject_AsFileDescriptor(). Other os.f* methods may suffer from the same issue. |
|
|
msg66516 - (view) |
Author: Neil Muller (Neil Muller) |
Date: 2008-05-10 13:04 |
The attached patch changes most functions in posixmodule which require a filedescriptor to use PyObjectAsDescriptor There are a few cases, where I'm not certain of the usefulness of changing the functions to support objects with fileno that I've left untouched. These are: tcgetpgrp tcsetpgrp closerange dup2 fdopen isatty The extension to these cases is trivial, though. |
|
|
msg66522 - (view) |
Author: Neil Muller (Neil Muller) |
Date: 2008-05-10 13:55 |
Patches to test_posix.py to also test using file objects in os.fstat and such. |
|
|
msg66624 - (view) |
Author: Neil Muller (Neil Muller) |
Date: 2008-05-11 12:42 |
This patch combines the two earlier patches, and also updates the docstrings and os.rst to reflect the changed behaviour. |
|
|
msg87623 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2009-05-12 13:20 |
Please produce a single patch comprising all changes. Also, there seem to be some misindentations in the modified C code. |
|
|
msg88977 - (view) |
Author: Neil Muller (Neil Muller) |
Date: 2009-06-05 22:10 |
Updated combined patch for python trunk added (indentation issues hopefully also fixed). |
|
|
msg88979 - (view) |
Author: Neil Muller (Neil Muller) |
Date: 2009-06-05 22:30 |
Similar patch for the python 3 branch. |
|
|
msg101709 - (view) |
Author: Neil Muller (Neil Muller) |
Date: 2010-03-25 15:45 |
Poking this issue with updated patches. Patch against py3k. |
|
|
msg101713 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2010-03-25 16:00 |
Actually, I'm not sure it's a good idea. For example, calling os.ftruncate(fobj) on a py3k file object will bypass the object's internal buffering, ignoring any pending buffered data; the right thing to do is to call fobj.truncate() instead. It may be better to simply mention in the docs that fileno() can be used on file-like objects to get a file descriptor, if needed. |
|
|
msg101718 - (view) |
Author: Neil Muller (Neil Muller) |
Date: 2010-03-25 16:23 |
Fair enough. Possible doc patch attached. |
|
|
msg101719 - (view) |
Author: Neil Muller (Neil Muller) |
Date: 2010-03-25 16:45 |
More fleshed out doc patch. Mention caveats about using file descriptors directly, add note to ftruncate similar to that for other dangerous methods. |
|
|
msg102144 - (view) |
Author: Georg Brandl (georg.brandl) *  |
Date: 2010-04-02 08:39 |
I applied the first part of the patch in r79580. I don't see that the second part is necessary, the other functions don't have such a note. |
|
|