Skip to content

BytesIO and StringIO issues with large sizes #160781

Open

Description

@cmaloney

Bug report

  1. BytesIO and StringIO .truncate reject sizes above 2**31 - 1 on Windows. This was introduced in a move from Argument Clinic converters to hand conversion (BytesIO in Segfault/abort from calling BytesIO unshare_buffer in threads on a free-threaded build #132551, StringIO in fix thread safety of io.StringIO.truncate #133732).

  2. BytesIO.write near sys.maxsize raises SystemError instead of OverflowError.

    import io, sys
    b = io.BytesIO(b"abc")
    b.seek(sys.maxsize - 1)
    b.write(b"x")

Found while working on gh-71448

CPython versions tested on:

CPython main branch, 3.14, 3.15

Operating systems tested on:

Linux, Windows

Linked PRs

Activity

  1. self-assigned this
    on Oct 27, 2026
  2. added
    type-bugAn unexpected behavior, bug, or error
    3.14bugs and security fixes
    3.15bugs and security fixes
    3.16new features, bugs and security fixes
    on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixes3.15bugs and security fixes3.16new features, bugs and security fixesOS-linuxOS-windowsextension-modulesC modules in the Modules dirtopic-IOtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions