diff --git a/Cargo.toml b/Cargo.toml index 364fbac8..54779c5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,6 +112,9 @@ py-clone = [] # Optimizes PyObject to Vec conversion and so on. nightly = [] +# Disables the checks for use in subinterpreters. +unsafe-allow-subinterpreters = [] + # Activates all additional features # This is mostly intended for testing purposes - activating *all* of these isn't particularly useful. full = [ diff --git a/src/impl_/pymodule.rs b/src/impl_/pymodule.rs index b05652bc..cb76547c 100644 --- a/src/impl_/pymodule.rs +++ b/src/impl_/pymodule.rs @@ -107,7 +107,7 @@ impl ModuleDef { // that static data is not reused across interpreters. // // PyPy does not have subinterpreters, so no need to check interpreter ID. - #[cfg(not(any(PyPy, GraalPy)))] + #[cfg(not(any(PyPy, GraalPy, feature = "unsafe-allow-subinterpreters")))] { // PyInterpreterState_Get is only available on 3.9 and later, but is missing // from python3.dll for Windows stable API on 3.9