Skip to content

Conversation

charris
Copy link
Member

@charris charris commented Mar 24, 2025

Backport of #28453.

Description

This PR fixes a type mismatch in the Cython declarations for the NpyIter_GetIterNext function.

The function was incorrectly declared to return NpyIter_IterNextFunc* (pointer to function type) when it should return NpyIter_IterNextFunc (function type directly). This mismatch causes compilation errors when users try to build Cython code that uses this function.

Solution

Modified both __init__.pxd and __init__.cython-30.pxd to remove the asterisk from the return type:

From:

NpyIter_IterNextFunc* NpyIter_GetIterNext(NpyIter* it, char** errmsg) except NULL

To:

NpyIter_IterNextFunc NpyIter_GetIterNext(NpyIter* it, char** errmsg) except NULL

Verification

The original issue demonstrates the problem with concrete compiler errors showing the incompatible pointer type assignment:

polyagamma/_polyagamma.c:6265:16: error: assignment to 'int (**)(NpyIter *)' from incompatible pointer type 'int (*)(NpyIter *)' [-Wincompatible-pointer-types]

This error occurs because the function returns a function pointer directly, not a pointer to a function pointer. Removing the asterisk in the declaration fixes this type mismatch.

References

Fixes #28446

@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Mar 24, 2025
@charris charris added this to the 2.2.5 release milestone Mar 24, 2025
@charris charris merged commit a2bef20 into numpy:maintenance/2.2.x Mar 24, 2025
70 checks passed
@charris charris deleted the backport-28453 branch March 24, 2025 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 08 - Backport Used to tag backport PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants