diff --git a/src/impl_/pymodule.rs b/src/impl_/pymodule.rs
index 7f8d4f9..db4972a 100644
--- a/src/impl_/pymodule.rs
+++ b/src/impl_/pymodule.rs
@@ -131,7 +131,7 @@ impl ModuleDef {
         //
         // TODO: it should be possible to use the Py_mod_multiple_interpreters slot on sufficiently
         // new Python versions to remove the need for this custom logic
-        #[cfg(not(any(PyPy, GraalPy)))]
+        #[cfg(not(any(PyPy, GraalPy, pyo3_unsafe_allow_subinterpreters)))]
         {
             // PyInterpreterState_Get is missing from python3.dll for Windows
             // stable API on 3.9
