mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
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.
This commit is contained in:
parent
9f7bbafffe
commit
db68bfc771
3 changed files with 10 additions and 2 deletions
|
|
@ -553,8 +553,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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue