| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
This does not look right. If IS_CLOSED() returns a positive value and sets an error, there is a bug in IS_CLOSED().
Sorry, something went wrong.
|
@serhiy-storchaka : Overall problem is code assumes IS_CLOSED can't result in an exception being set but if a user-provided implementation does unusual things (ex. closed = NotImplemented) then that breaks. 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. |
Sorry, something went wrong.
|
IS_CLOSED() should return -1 on error. |
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
|
Should I still be using PyErr_Occurred() or based on @serhiy-storchaka's feedback, should we make IS_CLOSED() return -1 on exception and check the sign in both CHECK_CLOSED() and _io__Buffered_close_impl()? |
Sorry, something went wrong.
|
PyErr_Occurred() is only used when we cannot distinguish the value signalling an error from a valid value, like in PyLong_AsLong(). IS_CLOSED() returns -1 on error, 0 -- false, 1 -- true. Or so it should be. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM. 👍
Sorry, something went wrong.
…redWriter (pythonGH-140653) They could raise SystemError or crash when getting the "closed" attribute or converting it to boolean raises an exception.
| Back | FazBrowse Home | New Git URL |
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_closed to IS_CLOSED.