-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: duplicate message print if warning raises an exception #10257
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
If you want to backport this, then it would be easiest if you rebase on 1368cbb And you missed the |
@@ -475,22 +475,10 @@ array_dealloc(PyArrayObject *self) | |||
"called."; | |||
/* 2017-Nov-10 1.14 */ | |||
if (DEPRECATE(msg) < 0) { | |||
/* dealloc must not raise an error, best effort try to write | |||
/* dealloc cannot raise an error, best effort try to write | |||
to stderr and clear the error |
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.
I think you might need to actually clear the error before calling PyArray_ResolveWritebackIfCopy
, in case the array is an object dtype, and PyArray_ResolveWritebackIfCopy
causes refcounts to drop to zero which can run arbitrary python code
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.
Although I suppose that's an unrelated fix
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.
In the implementation of PyErr_WriteUnraisable
it calls PyErr_Fetch
which clears the error state
hopefully rebased correctly, off the first fix to PR #9639 |
Thanks @mattip. |
As per the discussion here
PyErr_WriteUnraisable(obj)
first prints the error context fromPyErr_Fetch
(which already prints the message) and then printsrepr(obj)
. The old code thus printed the message twice. This PR prints once then, for lack of a better context, shows that the problem originated in an ndarray.If not too late perhaps this should be backported to 1.14