Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: allow subinterpreters to be manually disabled#5708
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -256,9 +256,13 @@ | ||
| // Slightly faster code paths are available when PYBIND11_HAS_SUBINTERPRETER_SUPPORT is *not* | ||
| // defined, so avoid defining it for implementations that do not support subinterpreters. However, | ||
| // defining it unnecessarily is not expected to break anything. | ||
| #if PY_VERSION_HEX >= 0x030C0000 && !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON) | ||
| # define PYBIND11_HAS_SUBINTERPRETER_SUPPORT | ||
| // defining it unnecessarily is not expected to break anything (other than old iOS targets). | ||
| #ifndef PYBIND11_HAS_SUBINTERPRETER_SUPPORT | ||
| # if PY_VERSION_HEX >= 0x030C0000 && !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON) | ||
| # define PYBIND11_HAS_SUBINTERPRETER_SUPPORT 1 | ||
| # else | ||
| # define PYBIND11_HAS_SUBINTERPRETER_SUPPORT 0 | ||
| # endif | ||
Comment on lines
+261
to
+265
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing defined/undefined to 1/0 is a backward-incompatible change, which breaks preprocessor See also: /* Define to 1 when compiling for experimental free-threaded builds */#ifdefPy_GIL_DISABLED/* We undefine if it was set to zero because all later checks are #ifdef. * Note that non-Windows builds do not do this, and so every effort should * be made to avoid defining the variable at all when not desired. However, * sysconfig.get_config_var always returns a 1 or a 0, and so it seems likely * that a build backend will define it with the value. */# ifPy_GIL_DISABLED==0# undef Py_GIL_DISABLED
# endif#endifCollaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I was aware of that when I reviewed this PR. My judgement: That's OK/best in this case, because that define was added only very recently, and was included only in release candidates. CollaboratorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Release candidates exist exactly so that we can make last minute backward in compatible changes to new features. :)
| ||
| #endif | ||
| // 3.12 Compatibility | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -324,7 +324,7 @@ inline std::atomic<int> &get_num_interpreters_seen() { | ||
| template <typename InternalsType> | ||
| inline std::unique_ptr<InternalsType> *&get_internals_pp() { | ||
| #ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT | ||
| #if PYBIND11_HAS_SUBINTERPRETER_SUPPORT | ||
henryiii marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if (get_num_interpreters_seen() > 1) { | ||
| // Internals is one per interpreter. When multiple interpreters are alive in different | ||
| // threads we have to allow them to have different internals, so we need a thread_local. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -15,7 +15,7 @@ | ||
| #include <stdexcept> | ||
| #if !defined(PYBIND11_HAS_SUBINTERPRETER_SUPPORT) | ||
| #if !PYBIND11_HAS_SUBINTERPRETER_SUPPORT | ||
henryiii marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| # error "This platform does not support subinterpreters, do not include this file." | ||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.