diff --git a/Cargo.toml b/Cargo.toml index ba5c3461..4d47e7d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,6 +109,9 @@ gil-refs = [] # 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 9ca80e39..58e2e4dc 100644 --- a/src/impl_/pymodule.rs +++ b/src/impl_/pymodule.rs @@ -85,7 +85,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(PyPy))] + #[cfg(not(any(PyPy, 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