Issue #20699: Document that “io” methods accept bytes-like objects
This matches the usage of ZipFile and BufferedWriter. This still requires
return values to be bytes() objects.
Also document and test that the write() methods should only access their
argument before they return.
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index dbd604a..83b6a32 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -836,7 +836,7 @@
b: Py_buffer
/
-Write bytes b to file, return number written.
+Write buffer b to file, return number of bytes written.
Only makes one system call, so not all of the data may be written.
The number of bytes actually written is returned. In non-blocking mode,
@@ -845,7 +845,7 @@
static PyObject *
_io_FileIO_write_impl(fileio *self, Py_buffer *b)
-/*[clinic end generated code: output=b4059db3d363a2f7 input=ffbd8834f447ac31]*/
+/*[clinic end generated code: output=b4059db3d363a2f7 input=6e7908b36f0ce74f]*/
{
Py_ssize_t n;
int err;