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
Use return converters and a typed setter value for _io accessors
The getters which return a boolean or an integer now use the bool, long
and Py_ssize_t return converters, and the TextIOWrapper._CHUNK_SIZE
setter declares its value as Py_ssize_t.

An out of range _CHUNK_SIZE now raises OverflowError instead of
ValueError.
  • Loading branch information
serhiy-storchaka committed Sep 19, 2026
commit 07dfaaa63e46559d2c8674d99ee5d6f530919484
8 changes: 4 additions & 4 deletions Lib/test/test_io/test_textio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,13 +1458,13 @@ def test_chunk_size(self):
t._CHUNK_SIZE = 0
with self.assertRaises(TypeError):
t._CHUNK_SIZE = 'x'
with self.assertRaises(ValueError):
with self.assertRaises(OverflowError):
t._CHUNK_SIZE = sys.maxsize + 1
with self.assertRaises(ValueError):
with self.assertRaises(OverflowError):
t._CHUNK_SIZE = -sys.maxsize - 2
with self.assertRaises(ValueError):
with self.assertRaises(OverflowError):
t._CHUNK_SIZE = 2**1000
with self.assertRaises(ValueError):
with self.assertRaises(OverflowError):
t._CHUNK_SIZE = -2**1000
with self.assertRaisesRegex(AttributeError, 'cannot be deleted'):
del t._CHUNK_SIZE
Expand Down
8 changes: 4 additions & 4 deletions Modules/_io/bytesio.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,16 @@ write_bytes_lock_held(bytesio *self, PyObject *b)
/*[clinic input]
@critical_section
@getter
_io.BytesIO.closed
_io.BytesIO.closed -> bool

True if the file is closed.
[clinic start generated code]*/

static PyObject *
static int
_io_BytesIO_closed_get_impl(bytesio *self)
/*[clinic end generated code: output=3210245d480df846 input=53d116fdfe4e7580]*/
/*[clinic end generated code: output=7cdc647cc7a71683 input=0687f923344225ee]*/
{
return PyBool_FromLong(self->buf == NULL);
return self->buf == NULL;
}

/*[clinic input]
Expand Down
12 changes: 9 additions & 3 deletions Modules/_io/clinic/bytesio.c.h

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

44 changes: 37 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.

16 changes: 13 additions & 3 deletions Modules/_io/clinic/iobase.c.h

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

22 changes: 17 additions & 5 deletions Modules/_io/clinic/stringio.c.h

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

30 changes: 24 additions & 6 deletions Modules/_io/clinic/textio.c.h

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

30 changes: 25 additions & 5 deletions Modules/_io/clinic/winconsoleio.c.h

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

Loading
Loading