-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
gh-140650: fix SystemError in io.BufferedWriter.close when closed errors #140653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look right. If IS_CLOSED() returns a positive value and sets an error, there is a bug in IS_CLOSED().
|
@serhiy-storchaka : Overall problem is code assumes Another option here is "Exception" can be turned into a True result for "IS_CLOSED" + clear the exception but that seems like hiding an implemention issue rather than helping resolve it to me. |
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also update CHECK_CLOSED to handle IS_CLOSED returning non-zero + setting an exception. In particular, if there's an exception CHECK_CLOSED should always return.
|
Should I still be using |
|
|
efimov-mikhail
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Misc/NEWS.d/next/Library/2025-10-27-00-40-49.gh-issue-140650.DYJPJ9.rst
Outdated
Show resolved
Hide resolved
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
…redWriter (pythonGH-140653) They could raise SystemError or crash when getting the "closed" attribute or converting it to boolean raises an exception.
Restores the 3.14 behavior of emitting a TypeError. Preservation of the sign helps in the error checking here:
cpython/Modules/_io/bufferedio.c
Lines 556 to 563 in 3dab11f
db68bfc changed from
buffered_closedtoIS_CLOSED.