diff --git a/Cargo.toml b/Cargo.toml index 7fe4af7e..7a51cf1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,6 +98,9 @@ auto-initialize = [] # 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 7c5243fc..aa668100 100644 --- a/src/impl_/pymodule.rs +++ b/src/impl_/pymodule.rs @@ -84,7 +84,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