Skip to content

Garbage collection of the BytesIO buffer object raises an unraisable exception #111331

Closed

Description

@serhiy-storchaka

Bug report

The following code

from io import BytesIO
memio = BytesIO(b"1234567890")
buf = memio.getbuffer()
del memio
a = [buf]
del buf
a.append(a)
del a
import gc
gc.collect()

raises an unraisable exception:

Exception ignored in: <_io.BytesIO object at 0x7fe2404d0d70>
Traceback (most recent call last):
  File "<python-input-9>", line 1, in <module>
BufferError: Existing exports of data: object cannot be re-sized

Unraisable exception during garbage collection is a sign of a bug.

It is only for the C implementation. The Python implementation raises an unraisable exception in different situation. See #111330.

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directory
    3.11only security fixes
    3.12only security fixes
    3.13only security fixes
    on Oct 25, 2023
  2. added a commit that references this issue on Aug 14, 2026
  3. added
    3.16new features, bugs and security fixes
    and removed
    3.11only security fixes
    3.12only security fixes
    3.13only security fixes
    on Aug 14, 2026
  4. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.16new features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-IOtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions