Skip to content

Fix PyArray_DTypeMeta definition when Py_LIMITED_API is disabled#532

Open
mattiapenati wants to merge 1 commit intoPyO3:mainfrom
mattiapenati:limited-api
Open

Fix PyArray_DTypeMeta definition when Py_LIMITED_API is disabled#532
mattiapenati wants to merge 1 commit intoPyO3:mainfrom
mattiapenati:limited-api

Conversation

@mattiapenati
Copy link
Contributor

When Py_LIMITED_API is disabled, PyArray_DTypeMeta has a different memory layout than PyTypeObject. This is explicitly documented in the NumPy C-API reference, which states that PyArray_DTypeMeta contains additional fields beyond those in PyTypeObject.

This structure is confirmed by the header file definition.

Copy link
Contributor

@Icxolu Icxolu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, looks like this is a npyffi fix only and was not used within our abstraction layer itself as far as I can see.

I think we are still missing a field in the struct. Also could you please add a changelog entry for this fix.

Comment on lines 557 to 558
pub singleton: *mut PyArray_Descr,
pub scalar_type: *mut PyTypeObject,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the type_num field is missing here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much! I completely missed that field.

@mattiapenati
Copy link
Contributor Author

I updated the changelog and wrote "unreleased" because I'm not sure what version number to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants