import io input_lines = ['windows\r\n'] joined = ''.join(input_lines) encoding = 'utf-8' newline = None bufsize = 1 raw = io.BytesIO(joined.encode(encoding)) buf = io.BufferedReader(raw, buffer_size=bufsize) textio = io.TextIOWrapper(buf, encoding=encoding, newline=newline) textio.seek(2**63 - 1) _ = textio.read(2)
python: ../Modules/_io/bytesio.c:616: _io_BytesIO_readinto_impl: Assertion `self->pos + len < PY_SSIZE_T_MAX' failed. Aborted (core dumped)
CPython main branch
Linux
More minimal reproducer:
import io res = bytearray(2) raw = io.BytesIO() raw.seek(2**63 - 1) _ = raw.readinto(res)
There's an assert that self->pos (2**63-1) + len (2) should not overflow, but there should probably be an error emitted (or update to handle larger sizes):
cpython/Modules/_io/bytesio.c
Lines 616 to 617 in 807db68
pythongh-141311: Avoid assertion in BytesIO readinto
gh-141311: Avoid assertion in BytesIO.readinto() (GH-141333)
pythongh-141311: Avoid assertion in BytesIO.readinto() (pythonGH-141333)
[3.14] gh-141311: Avoid assertion in BytesIO.readinto() (GH-141333) (G…
[3.13] gh-141311: Avoid assertion in BytesIO.readinto() (GH-141333) (G…
Activity
cmaloney commented on Nov 9, 2025
More minimal reproducer:
There's an assert that self->pos (2**63-1) + len (2) should not overflow, but there should probably be an error emitted (or update to handle larger sizes):
cpython/Modules/_io/bytesio.c
Lines 616 to 617 in 807db68
pythongh-141311: Avoid assertion in BytesIO readinto
gh-141311: Avoid assertion in BytesIO.readinto() (GH-141333)
pythongh-141311: Avoid assertion in BytesIO.readinto() (pythonGH-141333)
[3.14] gh-141311: Avoid assertion in BytesIO.readinto() (GH-141333) (G…
[3.13] gh-141311: Avoid assertion in BytesIO.readinto() (GH-141333) (G…
pythongh-141311: Avoid assertion in BytesIO.readinto() (pythonGH-141333)