[issue5883] detach() implementation
Antoine Pitrou
report at bugs.python.org
Thu Apr 30 18:04:49 CEST 2009
Antoine Pitrou <pitrou at free.fr> added the comment:
http://codereview.appspot.com/52075/diff/1/2
File Doc/library/io.rst (right):
http://codereview.appspot.com/52075/diff/1/2#newcode366
Line 366: Disconnect this buffer from its underlying raw stream and
return it.
This sentence is a bit ambiguous.
How about “Separate the underlying raw stream from the
:class:`BufferedIOBase` and return it” ?
Also, you should mention that some implementations will raise
io.UnsupportedOperation if the operation doesn't make sense.
http://codereview.appspot.com/52075/diff/1/2#newcode605
Line 605: in an unusable state.
You should mention that some implementations will raise
io.UnsupportedOperation if the operation doesn't make sense.
http://codereview.appspot.com/52075/diff/1/3
File Lib/_pyio.py (right):
http://codereview.appspot.com/52075/diff/1/3#newcode836
Line 836: return self
Uh, this doesn't really make sense. Better let it raise
io.UnsupportedOperation.
http://codereview.appspot.com/52075/diff/1/4
File Lib/test/test_io.py (right):
http://codereview.appspot.com/52075/diff/1/4#newcode532
Line 532: self.assertIs(buf.detach(), raw)
Perhaps a test of what happens when calling detach() a second time?
(it should probably raise a ValueError)
http://codereview.appspot.com/52075/diff/1/4#newcode1504
Line 1504: self.assertIs(t.detach(), b)
Same comment as for buffered binary tests.
http://codereview.appspot.com/52075/diff/1/5
File Modules/_io/bufferedio.c (right):
http://codereview.appspot.com/52075/diff/1/5#newcode470
Line 470: Py_CLEAR(self->raw);
Why not the simpler:
raw = self->raw;
self->raw = NULL;
?
http://codereview.appspot.com/52075/diff/1/5#newcode1547
Line 1547: self->detached = 1;
This should be 0.
http://codereview.appspot.com/52075/diff/1/6
File Modules/_io/textio.c (right):
http://codereview.appspot.com/52075/diff/1/6#newcode1080
Line 1080: "raw stream has been detached"); \
"underlying buffer" rather than "raw stream"?
http://codereview.appspot.com/52075/diff/1/6#newcode1092
Line 1092: "raw stream has been detached"); \
same as above
http://codereview.appspot.com/52075/diff/1/6#newcode1112
Line 1112: Py_CLEAR(self->buffer);
Why not the simpler:
buffer = self->buffer;
self->buffer = NULL;
?
http://codereview.appspot.com/52075
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5883>
_______________________________________
More information about the Python-bugs-list
mailing list