Skip to content

fix: follow rest of pybind11 closer with PYBIND11_HAS_SUBINTERPRETER_SUPPORT #5710

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

Conversation

henryiii
Copy link
Collaborator

@henryiii henryiii commented Jun 2, 2025

Description

See #5708, this is closer to how the other HAS_ defines work, while still supporting a user override.

Suggested changelog entry:

  • Internal adjustment to PYBIND11_HAS_SUBINTERPRETER_SUPPORT.

henryiii and others added 2 commits June 2, 2025 12:05
…SUPPORT

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
@henryiii henryiii requested review from rwgk and Copilot and removed request for rwgk June 2, 2025 19:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adjusts the handling of subinterpreter support to more closely mirror other PYBIND11 configuration defines and to allow for user override. Key changes include:

  • Updating test files (both Python and C++) to reference the new attribute "defined_PYBIND11_HAS_SUBINTERPRETER_SUPPORT".
  • Modifying preprocessor checks in header files to use "#ifdef"/"#ifndef" and adjusting macro logic in common.h.
  • Ensuring consistency between shared and per interpreter modules in how subinterpreter support is indicated.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_multiple_interpreters.py Updated attribute check from PYBIND11_HAS_SUBINTERPRETER_SUPPORT to defined_PYBIND11_HAS_SUBINTERPRETER_SUPPORT.
tests/test_embed/test_subinterpreter.cpp Switched from "#if" to "#ifdef" for subinterpreter support macro conditional.
tests/mod_shared_interpreter_gil.cpp Revised module attribute assignment to reflect the new user override approach.
tests/mod_per_interpreter_gil.cpp Revised module attribute assignment to reflect the new user override approach.
include/pybind11/subinterpreter.h Changed macro guard from "#if !PYBIND11_HAS_SUBINTERPRETER_SUPPORT" to "#ifndef" for clarity.
include/pybind11/detail/internals.h Updated macro check from "#if" to "#ifdef" to align with the revised handling.
include/pybind11/detail/common.h Added user override logic and updated the macro definition/undefining conditions.
Comments suppressed due to low confidence (1)

tests/test_multiple_interpreters.py:30

  • The updated attribute name 'defined_PYBIND11_HAS_SUBINTERPRETER_SUPPORT' is clear given the user override changes; consider updating the documentation to clarify its intentional distinction from 'PYBIND11_HAS_SUBINTERPRETER_SUPPORT'.
if not m.defined_PYBIND11_HAS_SUBINTERPRETER_SUPPORT:

Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

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

Thanks @henryiii!

@henryiii henryiii merged commit 9295c4a into pybind:master Jun 2, 2025
146 of 147 checks passed
@henryiii henryiii deleted the henryiii/chore/PYBIND11_HAS_SUBINTERPRETER_SUPPORT branch June 2, 2025 20:08
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs changelog Possibly needs a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants