@@ -121,7 +121,7 @@ resize_buffer(bytesio *self, size_t size)
121121}
122122
123123/* Internal routine for writing a string of bytes to the buffer of a BytesIO
124- object. Returns the number of bytes wrote , or -1 on error. */
124+ object. Returns the number of bytes written , or -1 on error. */
125125static Py_ssize_t
126126write_bytes (bytesio * self , const char * bytes , Py_ssize_t len )
127127{
@@ -171,10 +171,20 @@ bytesio_get_closed(bytesio *self)
171171 }
172172}
173173
174+ PyDoc_STRVAR (readable_doc ,
175+ "readable() -> bool. Returns True if the IO object can be read." );
176+
177+ PyDoc_STRVAR (writable_doc ,
178+ "writable() -> bool. Returns True if the IO object can be written." );
179+
180+ PyDoc_STRVAR (seekable_doc ,
181+ "seekable() -> bool. Returns True if the IO object can be seeked." );
182+
174183/* Generic getter for the writable, readable and seekable properties */
175184static PyObject *
176- return_true (bytesio * self )
185+ return_not_closed (bytesio * self )
177186{
187+ CHECK_CLOSED (self );
178188 Py_RETURN_TRUE ;
179189}
180190
@@ -867,9 +877,9 @@ static PyGetSetDef bytesio_getsetlist[] = {
867877};
868878
869879static struct PyMethodDef bytesio_methods [] = {
870- {"readable" , (PyCFunction )return_true , METH_NOARGS , NULL },
871- {"seekable" , (PyCFunction )return_true , METH_NOARGS , NULL },
872- {"writable" , (PyCFunction )return_true , METH_NOARGS , NULL },
880+ {"readable" , (PyCFunction )return_not_closed , METH_NOARGS , readable_doc },
881+ {"seekable" , (PyCFunction )return_not_closed , METH_NOARGS , seekable_doc },
882+ {"writable" , (PyCFunction )return_not_closed , METH_NOARGS , writable_doc },
873883 {"close" , (PyCFunction )bytesio_close , METH_NOARGS , close_doc },
874884 {"flush" , (PyCFunction )bytesio_flush , METH_NOARGS , flush_doc },
875885 {"isatty" , (PyCFunction )bytesio_isatty , METH_NOARGS , isatty_doc },
0 commit comments