diff --git a/include/pybind11/detail/internals.h b/include/pybind11/detail/internals.h index 7107b70688..295485ffab 100644 --- a/include/pybind11/detail/internals.h +++ b/include/pybind11/detail/internals.h @@ -101,7 +101,11 @@ class thread_specific_storage { // However, in GraalPy (as of v25.0 or older), TSS is implemented by Java and this call // requires a living Python interpreter. #ifdef GRAALVM_PYTHON +# if PY_VERSION_HEX >= 0x030D0000 + if (Py_IsInitialized() == 0 || Py_IsFinalizing() != 0) { +# else if (Py_IsInitialized() == 0 || _Py_IsFinalizing() != 0) { +# endif return; } #endif