Skip to content
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

[C API] Py_MOD_PER_INTERPRETER_GIL_SUPPORTED added to limited C API without versionning #110968

Closed
vstinner opened this issue Oct 17, 2023 · 4 comments

Comments

@vstinner
Copy link
Member

vstinner commented Oct 17, 2023

Three constants for PyModuleDef_Slot were added to the limited C API in Python 3.13:

  • Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED
  • Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED
  • Py_MOD_PER_INTERPRETER_GIL_SUPPORTED

Problem: there are added without version, as if they are available on Python 3.12 and older, whereas it's not the case.

cc @encukou @ericsnowcurrently

Linked PRs

vstinner added a commit to vstinner/cpython that referenced this issue Oct 17, 2023
* Only add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED to limited C API
  version 3.13.
* errno, xxlimited and _ctypes_test extensions now need the limited C
  API version 3.13 to get Py_MOD_PER_INTERPRETER_GIL_SUPPORTED.  They
  now include standard header files explicitly: <errno.h>, <string.h>
  and <stdio.h>.
* xxlimited_35: Remove Py_mod_multiple_interpreters slot,
  incompatible with limited C API version 3.5.
vstinner added a commit to vstinner/cpython that referenced this issue Oct 17, 2023
* Only add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED to limited C API
  version 3.13.
* errno, xxlimited and _ctypes_test extensions now need the limited C
  API version 3.13 to get Py_MOD_PER_INTERPRETER_GIL_SUPPORTED.  They
  now include standard header files explicitly: <errno.h>, <string.h>
  and <stdio.h>.
* xxlimited_35: Remove Py_mod_multiple_interpreters slot,
  incompatible with limited C API version 3.5.
vstinner added a commit that referenced this issue Oct 17, 2023
* Only add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED to limited C API
  version 3.13.
* errno, xxlimited and _ctypes_test extensions now need the limited C
  API version 3.13 to get Py_MOD_PER_INTERPRETER_GIL_SUPPORTED.  They
  now include standard header files explicitly: <errno.h>, <string.h>
  and <stdio.h>.
* xxlimited_35: Remove Py_mod_multiple_interpreters slot,
  incompatible with limited C API version 3.5.
@encukou
Copy link
Member

encukou commented Oct 17, 2023

IMO it's harmless to include these, even if they'd just be treated as false/true on older versions.

The bigger problem here is the slot ID, Py_mod_multiple_interpreters. It'll make the extension fail to load if used with an older version. That should definitely be in an #ifdef.

@ericsnowcurrently
Copy link
Member

Yeah, it was definitely unintentional to expose any of these in the wrong place.

Also, they were added to 3.12 (1c420e1), right before feature freeze. Would we be okay to add the version ifdefs in 3.12.1? (I'd think so, but I sometimes get this subtle sort of compatibility concern wrong.)

The bigger problem here is the slot ID, Py_mod_multiple_interpreters. It'll make the extension fail to load if used with an older version. That should definitely be in an #ifdef.

Agreed. gh-110969 missed fixing it.

@vstinner
Copy link
Member Author

vstinner commented Nov 1, 2023

Also, they were added to 3.12 (1c420e1), right before feature freeze. Would we be okay to add the version ifdefs in 3.12.1?

Oh, I missed that. I wrote PR #111584 to fix the version check in the main branch, and then I will backport the change to the 3.12 branch.

vstinner added a commit to vstinner/cpython that referenced this issue Nov 1, 2023
Constants like Py_MOD_PER_INTERPRETER_GIL_SUPPORTED were only added
to the limited C API version 3.12 and newer.
vstinner added a commit that referenced this issue Nov 1, 2023
….12 (#111588)

Constants like Py_MOD_PER_INTERPRETER_GIL_SUPPORTED were only added
to the limited C API version 3.12 and newer.
@vstinner vstinner closed this as completed Nov 3, 2023
FullteaR pushed a commit to FullteaR/cpython that referenced this issue Nov 3, 2023
@ericsnowcurrently
Copy link
Member

Thanks for taking care of this, @vstinner!

ericsnowcurrently added a commit that referenced this issue Nov 6, 2023
…MITED_API (gh-111707)

This should have been done in gh-104148.

(A similar fix has already be done for that slot's value macros, and backported to 3.12.  See gh-110968.)
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 6, 2023
… Py_LIMITED_API (pythongh-111707)

This should have been done in pythongh-104148.

(A similar fix has already be done for that slot's value macros, and backported to 3.12.  See pythongh-110968.)
(cherry picked from commit 836e0a7)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
hugovk pushed a commit to hugovk/cpython that referenced this issue Nov 8, 2023
… Py_LIMITED_API (pythongh-111707)

This should have been done in pythongh-104148.

(A similar fix has already be done for that slot's value macros, and backported to 3.12.  See pythongh-110968.)
ericsnowcurrently added a commit that referenced this issue Nov 28, 2023
…r Py_LIMITED_API (gh-111707) (gh-111787)

This should have been done in gh-104148.

(A similar fix has already be done for that slot's value macros, and backported to 3.12.  See gh-110968.)
(cherry picked from commit 836e0a7)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…ython#110969)

* Only add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED to limited C API
  version 3.13.
* errno, xxlimited and _ctypes_test extensions now need the limited C
  API version 3.13 to get Py_MOD_PER_INTERPRETER_GIL_SUPPORTED.  They
  now include standard header files explicitly: <errno.h>, <string.h>
  and <stdio.h>.
* xxlimited_35: Remove Py_mod_multiple_interpreters slot,
  incompatible with limited C API version 3.5.
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
… Py_LIMITED_API (pythongh-111707)

This should have been done in pythongh-104148.

(A similar fix has already be done for that slot's value macros, and backported to 3.12.  See pythongh-110968.)
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…ython#110969)

* Only add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED to limited C API
  version 3.13.
* errno, xxlimited and _ctypes_test extensions now need the limited C
  API version 3.13 to get Py_MOD_PER_INTERPRETER_GIL_SUPPORTED.  They
  now include standard header files explicitly: <errno.h>, <string.h>
  and <stdio.h>.
* xxlimited_35: Remove Py_mod_multiple_interpreters slot,
  incompatible with limited C API version 3.5.
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
… Py_LIMITED_API (pythongh-111707)

This should have been done in pythongh-104148.

(A similar fix has already be done for that slot's value macros, and backported to 3.12.  See pythongh-110968.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants