Skip to content

ENH: Update pythoncapi-compat and add Limited API fallbacks for Py_SETREF - #32871

Merged
mattip merged 8 commits into
numpy:mainfrom
prathamhole14:test_pythoncapi_compat_184
Oct 29, 2026
Merged

mattip merged 8 commits into
numpy:mainfrom
prathamhole14:test_pythoncapi_compat_184

Conversation

@prathamhole14

@prathamhole14 prathamhole14 commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

PR summary

Part of the Limited API work for _multiarray_umath.

Related to: #31913
Updates the pythoncapi-compat submodule to upstream main (ebbf075), which now supports the Limited API

@ngoldbaum

Copy link
Copy Markdown
Member

The upstream PR is merged so it should be safe to move this out of draft after pointing the submodule on upstream main.

@prathamhole14

Copy link
Copy Markdown
Member Author

This includes #32864, closing that one.

@prathamhole14 prathamhole14 changed the title TST: test pythoncapi-compat#184, do not merge ENH: Update pythoncapi-compat and add Limited API fallbacks for Py_SETREF Oct 8, 2026
@prathamhole14
prathamhole14 marked this pull request as ready for review October 8, 2026 13:22
@prathamhole14

Copy link
Copy Markdown
Member Author

Failing test is unrelated, I think we can merge this now and then I will push a small follow up to remove dead code because of python/pythoncapi-compat#187 when it is merged.

@mattip

mattip commented Oct 11, 2026

Copy link
Copy Markdown
Member

I think we should wait for python/pythoncapi-compat#187 to provide the macros.

@prathamhole14

Copy link
Copy Markdown
Member Author

I think we should wait for python/pythoncapi-compat#187 to provide the macros.

Maybe we can get this merged now and then in future I will do a follow to remove those macros once . I have a few PRs lined up like #32951

@ngoldbaum

Copy link
Copy Markdown
Member

@mattip except now we're in a position where we can't use the Py_SETREF and are forced to use workarounds. See #33175. I think we should merge this as-is.

#include "numpy/arrayobject.h"

#include "npy_config.h"
#include "npy_pycompat.h"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why does this file need the include? Likewise, there are other files with the include without any other changes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ahh, I get it.

@mattip
mattip merged commit 39f66c0 into numpy:main Oct 29, 2026
92 of 93 checks passed
@mattip

mattip commented Oct 29, 2026

Copy link
Copy Markdown
Member

Thanks @prathamhole14

@prathamhole14
prathamhole14 deleted the test_pythoncapi_compat_184 branch October 29, 2026 20:12
@vstinner

Copy link
Copy Markdown
Contributor

I'm glad that adding limited C API support to pythoncapi-compat is useful to numpy!

I'm sorry, I didn't investigate the Py_SETREF() issue on strict aliasing on Python upstream yet. Recently, I was busy with backporting many C API fixes from Python main to Python 3.14 and 3.15 branches, like backporting Py_CLEAR, Py_SETREF, Py_XSETREF changes and test_cext enhancements.

@vstinner

vstinner commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

See python/cpython#161186 for my Py_SETREF() strict aliasing fix.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants