8000 gh-101819: Refactor _io futher in preparation for module isolation by erlend-aasland · Pull Request #104369 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-101819: Refactor _io futher in preparation for module isolation #104369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 11, 2023
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.truncate
  • Loading branch information
erlend-aasland committed May 10, 2023
commit c4e0940955c6880d2be5f75017bbcbfaf7f5aa06
31 changes: 23 additions & 8 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 @@ -1000,6 +1000,7 @@ _io_FileIO_tell_impl(fileio *self)
#ifdef HAVE_FTRUNCATE
/*[clinic input]
_io.FileIO.truncate
cls: defining_class
size as posobj: object = None
/

Expand All @@ -1010,8 +1011,8 @@ The current file position is changed to the value of size.
[clinic start generated code]*/

static PyObject *
_io_FileIO_truncate_impl(fileio *self, PyObject *posobj)
/*[clinic end generated code: output=e49ca7a916c176fa input=b0ac133939823875]*/
_io_FileIO_truncate_impl(fileio *self, PyTypeObject *cls, PyObject *posobj)
/*[clinic end generated code: output=d936732a49e8d5a2 input=c367fb45d6bb2c18]*/
{
Py_off_t pos;
int ret;
Expand All @@ -1021,7 +1022,7 @@ _io_FileIO_truncate_impl(fileio *self, PyObject *posobj)
if (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
0