]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-138720: Make Buffered closed check match flush (GH-138724)
authorCody Maloney <cmaloney@users.noreply.github.com>
Thu, 18 Sep 2025 10:02:29 +0000 (03:02 -0700)
committerGitHub <noreply@github.com>
Thu, 18 Sep 2025 10:02:29 +0000 (12:02 +0200)
commitdb68bfc771e6a85573732e0b579e8f68841c9b5c
tree4ed1434670d77ef9fbb041d89886b3c100b3a061
parent9f7bbafffe1e2c025bb54b20388c9eb45edaebf5
gh-138720: Make Buffered closed check match flush (GH-138724)

In `_io__Buffered_flush_impl` the macro `CHECK_CLOSED` is used to check
the `buffered*` is in a good state to be flushed. That differs slightly
from `buffered_closed`.

In some cases, that difference would result in `close()` thinking the
file needed to be flushed and closed while `flush()` thought the file
was already closed.

This could happen during GC and would result in an unraisable exception.
Lib/test/test_io/test_general.py
Misc/NEWS.d/next/Library/2025-09-09-17-57-49.gh-issue-138720.hAtsm-.rst [new file with mode: 0644]
Modules/_io/bufferedio.c