Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Lib/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,10 @@ def test_readinto(self):
self.assertEqual(getattr(pair, method)(data), 5)
self.assertEqual(bytes(data), b"abcde")

# gh-138720: C BufferedRWPair would destruct in a bad order resulting in
# an unraisable exception.
support.gc_collect()

def test_write(self):
w = self.MockRawIO()
pair = self.tp(self.MockRawIO(), w)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix an issue where :class:`io.BufferedWriter` and :class:`io.BufferedRandom`
had different definitions of "closed" for :meth:`~io.IOBase.close` and
:meth:`~io.IOBase.flush` which resulted in an exception when close called
flush but flush thought the file was already closed.
4 changes: 2 additions & 2 deletions Modules/_io/bufferedio.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ _io__Buffered_close_impl(buffered *self)
if (!ENTER_BUFFERED(self)) {
return NULL;
}

r = buffered_closed(self);
/* gh-138720: Use IS_CLOSED to match flush CHECK_CLOSED. */
r = IS_CLOSED(self);
if (r < 0)
goto end;
if (r > 0) {
Expand Down
Loading