BUG: add missing error handling in public_dtype_api.c by ngoldbaum · Pull Request #27098 · numpy/numpy
Conversation
@SwayamInSync ran into some confusing behaviors working on a DType and I tracked it down to missing error handling here
Hard to write a test for this without defining an invalid DType.
mhvk approved these changes Aug 3, 2024
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Would also be good to update the comment for the actual routine, since currently it claims to do no error checking, which is perhaps what led to this mistake:
| /* | |
| * Internal version of PyArrayInitDTypeMeta_FromSpec. | |
| * | |
| * See the documentation of that function for more details. Does not do any | |
| * error checking. | |
| * Setting priv to a nonzero value indicates that a dtypemeta is being | |
| * initialized from inside NumPy, otherwise this function is being called by | |
| * the public implementation. | |
| */ | |
| NPY_NO_EXPORT int | |
| dtypemeta_initialize_struct_from_spec( | |
| PyArray_DTypeMeta *DType, PyArrayDTypeMeta_Spec *spec, int priv) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters