Two minor exception handling bugs
peytondmurray opened this issue · 2 comments
Posting these here before I forget about them:
- Here
PyErr_Occurred()is called without first callingPyGilState_Ensure. According to the docs, the caller must hold the GIL. - In
add_promoter, the call toPyCapsule_Newcan fail. I think we need to check whether the result isNULLand whether the error indicator is set, thenDECREFstuff appropriately.
Here PyErr_Occurred() is called without first calling PyGilState_Ensure
PyErr_Occurred has an assert for that in the implementation here. Also there are several other C API functions that get called in that function that need the GIL. Right now get_value is only used by setitem, which does not release the GIL on the numpy side, so I think we're safe. We could certainly add a documentation note saying that get_value needs the GIL.
In add_promoter, the call to PyCapsule_New can fail. I think we need to check whether the result is NULL and whether the error indicator is set, then DECREF stuff appropriately.
Good point, PR incoming.
The first is fine, getitem/setitem always hold the GIL, second is fixed, closing.