Skip to content

BUG: add missing error handling in public_dtype_api.c#27098

Merged
mattip merged 1 commit into
numpy:mainfrom
ngoldbaum:fix-error-handling
Aug 4, 2024
Merged

BUG: add missing error handling in public_dtype_api.c#27098
mattip merged 1 commit into
numpy:mainfrom
ngoldbaum:fix-error-handling

Conversation

@ngoldbaum

Copy link
Copy Markdown
Member

@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.

@ngoldbaum ngoldbaum added the 09 - Backport-Candidate PRs tagged should be backported label Aug 2, 2024

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

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)
{

@mattip mattip merged commit 972c16d into numpy:main Aug 4, 2024
@mattip

mattip commented Aug 4, 2024

Copy link
Copy Markdown
Member

Thanks @ngoldbaum

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants