msg231079 - (view) |
Author: Stanislaw Pitucha (viraptor) |
Date: 2014-11-12 15:06 |
The docstring on for fileno() method says: "An IOError is raised if the IO object does not use a file descriptor." In reality, UnsupportedOperation is raised instead: ``` : io.StringIO().fileno() UnsupportedOperation: fileno ``` |
|
|
msg231080 - (view) |
Author: Stanislaw Pitucha (viraptor) |
Date: 2014-11-12 15:08 |
Just in case: yes, UnsupportedOperation is an IOError - but shouldn't docstring here be more specific? |
|
|
msg231095 - (view) |
Author: Martin Panter (martin.panter) *  |
Date: 2014-11-12 21:36 |
Similarly for the readable(), seekable() and writable() documentation |
|
|
msg232989 - (view) |
Author: Martin Panter (martin.panter) *  |
Date: 2014-12-21 05:34 |
Some of the docstrings already mention UnsupportedOperation. This patch updates the rest of the documentation. Also adds some tests to verify this on all the concrete classes I could think of. Some discoveries in the process: * BufferedWriter.readable() and BufferedReader.writable() could return True depending on the underlying raw stream. Fixed to always return False. * Removed a branch in a test case that assumed BufferedReader.close() did not call flush(), but never activated due to the above writable() bug * seek(), tell() and truncate() do not raise UnsupportedOperation, despite seekable() == False, at least for a pipe. Adjusted doc strings. |
|
|
msg261728 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-03-14 07:33 |
Nice patch. But it isn't applied cleanly on current tip (perhaps due to Argument Clinic). Added comments and questions on Rietveld. |
|
|
msg261942 - (view) |
Author: Martin Panter (martin.panter) *  |
Date: 2016-03-18 02:01 |
Thanks for looking at this Serhiy. Here is patch v2, merged with 3.6 branch; some doc string changes were redundant with upstream Arg Clinic changes. However looking at this again, I think we should be cautious changing the documented exceptions for the base classes, since that is changing the API. E.g. perhaps it would be safer to leave the exception for fileno() as OSError (aka IOError). It it actually causing a problem? Or the API changes should be reserved for 3.6 only. |
|
|
msg261953 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-03-18 10:02 |
I have doubts about changing OSError to UnsupportedOperation in the documentation of readable() and writable(). Some implementations can try to do an IO operation without checking readable() and writable() flags. I have lesser doubt about using half-closed pipes in tests. May be it is safe, I don't know. |
|
|
msg262503 - (view) |
Author: Martin Panter (martin.panter) *  |
Date: 2016-03-27 01:26 |
Okay let’s document fileno(), read, write and seek operations in the base classes as raising OSError then. This effectively rejects the OP (Stanislaw’s) view that the exception should be more specific. In patch v3, I changed everything over to say OSError is raised. I also added a background thread to drain the pipe writer. And I removed a test_no_fileno() method which was having an “existential crisis”. :) |
|
|
msg262506 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-03-27 04:13 |
LGTM. |
|
|
msg262690 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-03-31 09:49 |
New changeset dc9e5f09ac0c by Martin Panter in branch '3.5': Issue #22854: Clarify documentation about UnsupportedOperation and add tests https://hg.python.org/cpython/rev/dc9e5f09ac0c New changeset c27e9dcad1a3 by Martin Panter in branch 'default': Issue #22854: Merge UnsupportedOperation fixes from 3.5 https://hg.python.org/cpython/rev/c27e9dcad1a3 |
|
|
msg262691 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-03-31 10:00 |
New changeset 3d9d9ca75a31 by Martin Panter in branch '2.7': Issue #22854: fileno() is always required in IOBase; remove test https://hg.python.org/cpython/rev/3d9d9ca75a31 |
|
|
msg262692 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-03-31 10:55 |
New changeset fb10d1f5016e by Martin Panter in branch 'default': Issue #22854: Skip pipe seekable() tests on Windows https://hg.python.org/cpython/rev/fb10d1f5016e |
|
|
msg262693 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-03-31 11:24 |
New changeset 66765a49465f by Martin Panter in branch '3.5': Issue #22854: Skip pipe seek tests on Windows https://hg.python.org/cpython/rev/66765a49465f New changeset 3b7811b58a1f by Martin Panter in branch 'default': Issue #22854: Merge Windows pipe skipping from 3.5 https://hg.python.org/cpython/rev/3b7811b58a1f |
|
|
msg262694 - (view) |
Author: Martin Panter (martin.panter) *  |
Date: 2016-03-31 11:32 |
I gave up on porting the fix to 2.7. Python 3 raises UnsupportedOperation (which inherits ValueError) in many cases due to Issue 9293, but Python 2 raises IOError (which does not inherit ValueError). Changing how BufferedWriter.read() etc work in Python 2 would break test_io_after_close(). Also, none of the doc strings in Python 2 need fixing. Also according to the buildbots, Windows can seek in pipes. Or at least tell() doesn’t raise an exception. So I skipped the seek testing on Windows. |
|
|
msg262708 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-03-31 21:24 |
New changeset b3c79e0ba477 by Martin Panter in branch '3.5': Issue #22854: Fix logic for skipping test https://hg.python.org/cpython/rev/b3c79e0ba477 New changeset de8412dc477e by Martin Panter in branch 'default': Issue #22854: Merge test fix from 3.5 https://hg.python.org/cpython/rev/de8412dc477e |
|
|