Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

_io.BufferedReader.read1() leaves object in reentrant state after MemoryError #143689

Open
Labels
@hyongtao-code

Description

@hyongtao-code

Bug report

Bug description:

BufferedReader.read1() can leave the object in a broken (reentrant) state after an allocation failure.

Reproducer

importioimportsysdefrepro():br=io.BufferedReader(io.BytesIO(b"hello world"),buffer_size=8)huge=10**18try:br.read1(huge)exceptExceptionase:print("first call exception:",type(e).__name__,e)try:x=br.read1(1)print("second call ok:",x)exceptExceptionase:print("second call exception:",type(e).__name__,e)br2=io.BufferedReader(io.BytesIO(b"hello world"),buffer_size=8)print("fresh object read1:",br2.read1(1))if__name__=="__main__":print("python:",sys.version)repro()

Wrong behavior

D:\MyCode\cpython\PCbuild\amd64>python_d.exe py_iobuffer.pypython: 3.15.0a3+ (heads/main-dirty:78e868fa28, Jan 11 2026, 12:40:52) [MSC v.1950 64 bit (AMD64)]first call exception: MemoryErrorsecond call exception: RuntimeError reentrant call inside<_io.BufferedReader>fresh object read1: b'h'Exception ignoredwhile finalizing file<_io.BufferedReader>:Traceback (most recent call last):  File"D:\MyCode\cpython\PCbuild\amd64\py_iobuffer.py", line 24,in<module>repro()~~~~~^^RuntimeError: reentrant call inside<_io.BufferedReader>

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp