Skip to content

MAINT: support python 3.10 #16417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 29, 2020
Merged

MAINT: support python 3.10 #16417

merged 3 commits into from
May 29, 2020

Conversation

tacaswell
Copy link
Contributor

@tacaswell tacaswell commented May 28, 2020

In python/cpython#20290 CPython changed
Py_TYPE from a macro to an inline function. This requires a code
change to us Py_SET_TYPE instead when using Py_TYPE() as a lvalue
in c code.

This is a draft (and I expect it to fail all of the tests) because Py_SET_TYPE was only introduced in py39. Can I please have some guidance on how to do version gating (or have someone who knows take over this PR ;) )

@charris
Copy link
Member

charris commented May 28, 2020

Ugh. Is it certain that this change will persist to release?

@eric-wieser
Copy link
Member

eric-wieser commented May 28, 2020

Something like this in npy3k.h (or however it's spelt) would do it:

#if PY_VERSION_HEX < 0x030a0000
    #define Py_SET_TYPE(obj, typ) (Py_TYPE(obj) = typ)
#endif

@tacaswell
Copy link
Contributor Author

This is part of a series of intentional API breaks to try and condense the python c-api so I am pretty confident that this will persist.

@seberg
Copy link
Member

seberg commented May 28, 2020

It seems like we should also replace all ob_type then... But, I guess no need to try and get ahead of Python here...

@charris
Copy link
Member

charris commented May 28, 2020

This is part of a series of intentional API breaks

We might want to make a compatibility include file to use until Python3.9 gets dropped. Probably need to use new names to avoid redefinitions.

@charris charris changed the title MNT: support python 3.10 MAINT: support python 3.10 May 29, 2020
@charris
Copy link
Member

charris commented May 29, 2020

We are running tests against 3.9-dev, so that should validate that this works.

tacaswell added 2 commits May 29, 2020 11:02
In python/cpython#20290 CPython changed
`Py_TYPE` from a macro to an inline function.  This requires a code
change to us `Py_SET_TYPE` instead when using `Py_TYPE()` as a lvalue
in c code.

In python/cpython#20429 CPython changed
`Py_SIZE` from a macro to an inline function.  This requires a code
change to us `Py_SET_SIZE` instead of using `Py_SIZE` as a lvalue in c
code.
To support the change to Py_SIZE and Py_TYPE the Py_SET_SIZE and
Py_SET_TYPE macros are provided in py39.  This provides the same
macros falling back to the old method for < py39.
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label May 29, 2020
@@ -546,4 +546,10 @@ NpyCapsule_Check(PyObject *ptr)
}
#endif

/* Introduced in https://github.com/python/cpython/commit/d2ec81a8c99796b51fb8c49b77a7fe369863226f */
Copy link
Member

@charris charris May 29, 2020

Choose a reason for hiding this comment

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

This might look better up top with the similar compatibility hacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should also add a reference for the other one.

@tacaswell tacaswell marked this pull request as ready for review May 29, 2020 17:00
@charris
Copy link
Member

charris commented May 29, 2020

The testing error is on the azure end and may be ignored.

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@charris charris merged commit a96b18e into numpy:master May 29, 2020
@charris
Copy link
Member

charris commented May 29, 2020

Thanks Thomas.

akihikodaki added a commit to akihikodaki/dts that referenced this pull request Feb 11, 2023
This includes a fix for Python 3.10:
numpy/numpy#16417

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
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