diff --git a/pytests/tests/test_misc.py b/pytests/tests/test_misc.py
index c3e03c04b09..9cc0cebc771 100644
--- a/pytests/tests/test_misc.py
+++ b/pytests/tests/test_misc.py
@@ -33,10 +33,15 @@ def test_multiple_imports_same_interpreter_ok():
 def test_import_in_subinterpreter_forbidden():
     import _xxsubinterpreters
 
+    if sys.version_info < (3, 12):
+        expected_error = "PyO3 modules do not yet support subinterpreters, see https://github.com/PyO3/pyo3/issues/576"
+    else:
+        expected_error = "module pyo3_pytests.pyo3_pytests does not support loading in subinterpreters"
+
     sub_interpreter = _xxsubinterpreters.create()
     with pytest.raises(
         _xxsubinterpreters.RunFailedError,
-        match="PyO3 modules do not yet support subinterpreters, see https://github.com/PyO3/pyo3/issues/576",
+        match=expected_error,
     ):
         _xxsubinterpreters.run_string(
             sub_interpreter, "import pyo3_pytests.pyo3_pytests"
diff --git a/src/impl_/pymodule.rs b/src/impl_/pymodule.rs
index 522341287c6..3095ce7ee9f 100644
--- a/src/impl_/pymodule.rs
+++ b/src/impl_/pymodule.rs
@@ -15,7 +15,7 @@ pub struct ModuleDef {
     ffi_def: UnsafeCell<ffi::PyModuleDef>,
     initializer: ModuleInitializer,
     /// Interpreter ID where module was initialized (not applicable on PyPy).
-    #[cfg(all(not(PyPy), Py_3_9))]
+    #[cfg(all(not(PyPy), Py_3_9, not(all(windows, Py_LIMITED_API, not(Py_3_10)))))]
     interpreter: AtomicI64,
     /// Initialized module object, cached to avoid reinitialization.
     module: GILOnceCell<Py<PyModule>>,
@@ -58,7 +58,7 @@ impl ModuleDef {
             ffi_def,
             initializer,
             // -1 is never expected to be a valid interpreter ID
-            #[cfg(all(not(PyPy), Py_3_9))]
+            #[cfg(all(not(PyPy), Py_3_9, not(all(windows, Py_LIMITED_API, not(Py_3_10)))))]
             interpreter: AtomicI64::new(-1),
             module: GILOnceCell::new(),
         }
@@ -86,7 +86,9 @@ impl ModuleDef {
         // PyPy does not have subinterpreters, so no need to check interpreter ID.
         #[cfg(not(PyPy))]
         {
-            #[cfg(Py_3_9)]
+            // PyInterpreterState_Get is only available on 3.9 and later, but is missing
+            // from python3.dll for Windows stable API on 3.9
+            #[cfg(all(Py_3_9, not(all(windows, Py_LIMITED_API, not(Py_3_10)))))]
             {
                 let current_interpreter =
                     unsafe { ffi::PyInterpreterState_GetID(ffi::PyInterpreterState_Get()) };
@@ -104,7 +106,7 @@ impl ModuleDef {
                     }
                 }
             }
-            #[cfg(not(Py_3_9))]
+            #[cfg(not(all(Py_3_9, not(all(windows, Py_LIMITED_API, not(Py_3_10))))))]
             {
                 // CPython before 3.9 does not have APIs to check the interpreter ID, so best that can be
                 // done to guard against subinterpreters is fail if the module is initialized twice