-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: Clear error before and after PyErr_WarnEx for 3118 buffers #9348
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
From a quick glance at the patch, the use of |
The usage of The issue itself arises after |
Why does it give a warning and not just error out at all? Not following python conventions is maybe not nice, but not so bad for an internal function, but I think the problem here may be that the function should be able to signal three and not two possible results:
And it seems for 3. it actually sets a warning in a pretty nasty way, since that warning can also easily be an exception. The second clear seemes to be more likely correct to do something of the logic EDIT: Or maybe split it into two functions, one that can't error and decides whether to try or not, the other that can error and the error will always be shown (possibly after deprecation). |
if (!PyBytes_Check(op) && !PyUnicode_Check(op)) { | ||
if (_array_from_buffer_3118(op, (PyObject **)out_arr) == 0) { | ||
if (writeable && | ||
PyArray_FailUnlessWriteable(*out_arr, "PEP 3118 buffer") < 0) { |
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 doesn't look safe if out_arr == NULL
...
Looks like |
Fixes #6741
The
PyErr_WarnEx
seems to be the reason of thePyObject_Call: Assertion
failure.Here I assumed that
PyErr_WarnEx
is primarily used to print the warning message and suppress all errors. ThusPyErr_Clear
should be safe to be used to clear the error which is turned into the warning and clear all errors possibly set by the warning.From PyErr_WarnEx
The tests relate to #6214