Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fetch module state by class in _io.FileIO.write
  • Loading branch information
erlend-aasland committed May 10, 2023
commit 097f14780081e26cc2fd4ecb90779626f09ace92
32 changes: 25 additions & 7 deletions Modules/_io/clinic/fileio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Modules/_io/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ _io_FileIO_read_impl(fileio *self, PyTypeObject *cls, Py_ssize_t size)

/*[clinic input]
_io.FileIO.write
cls: defining_class
b: Py_buffer
/

Expand All @@ -857,16 +858,16 @@ returns None if the write would block.
[clinic start generated code]*/

static PyObject *
_io_FileIO_write_impl(fileio *self, Py_buffer *b)
/*[clinic end generated code: output=b4059db3d363a2f7 input=6e7908b36f0ce74f]*/
_io_FileIO_write_impl(fileio *self, PyTypeObject *cls, Py_buffer *b)
/*[clinic end generated code: output=927e25be80f3b77b input=2776314f043088f5]*/
{
Py_ssize_t n;
int err;

if (self->fd < 0)
return err_closed();
if (!self->writable) {
_PyIO_State *state = IO_STATE();
_PyIO_State *state = get_io_state_by_cls(cls);
return err_mode(state, "writing");
}

Expand Down