@@ -15,7 +15,7 @@ pub struct ModuleDef {
15
15
ffi_def : UnsafeCell < ffi:: PyModuleDef > ,
16
16
initializer : ModuleInitializer ,
17
17
/// Interpreter ID where module was initialized (not applicable on PyPy).
18
- #[ cfg( all( not( PyPy ) , Py_3_9 ) ) ]
18
+ #[ cfg( all( not( PyPy ) , Py_3_9 , not ( all ( windows , Py_LIMITED_API , not ( Py_3_10 ) ) ) ) ) ]
19
19
interpreter : AtomicI64 ,
20
20
/// Initialized module object, cached to avoid reinitialization.
21
21
module : GILOnceCell < Py < PyModule > > ,
@@ -58,7 +58,7 @@ impl ModuleDef {
58
58
ffi_def,
59
59
initializer,
60
60
// -1 is never expected to be a valid interpreter ID
61
- #[ cfg( all( not( PyPy ) , Py_3_9 ) ) ]
61
+ #[ cfg( all( not( PyPy ) , Py_3_9 , not ( all ( windows , Py_LIMITED_API , not ( Py_3_10 ) ) ) ) ) ]
62
62
interpreter : AtomicI64 :: new ( -1 ) ,
63
63
module : GILOnceCell :: new ( ) ,
64
64
}
@@ -86,7 +86,9 @@ impl ModuleDef {
86
86
// PyPy does not have subinterpreters, so no need to check interpreter ID.
87
87
#[ cfg( not( PyPy ) ) ]
88
88
{
89
- #[ cfg( Py_3_9 ) ]
89
+ // PyInterpreterState_Get is only available on 3.9 and later, but is missing
90
+ // from python3.dll for Windows stable API on 3.9
91
+ #[ cfg( all( Py_3_9 , not( all( windows, Py_LIMITED_API , not( Py_3_10 ) ) ) ) ) ]
90
92
{
91
93
let current_interpreter =
92
94
unsafe { ffi:: PyInterpreterState_GetID ( ffi:: PyInterpreterState_Get ( ) ) } ;
@@ -104,7 +106,7 @@ impl ModuleDef {
104
106
}
105
107
}
106
108
}
107
- #[ cfg( not( Py_3_9 ) ) ]
109
+ #[ cfg( not( all ( Py_3_9 , not ( all ( windows , Py_LIMITED_API , not ( Py_3_10 ) ) ) ) ) ) ]
108
110
{
109
111
// CPython before 3.9 does not have APIs to check the interpreter ID, so best that can be
110
112
// done to guard against subinterpreters is fail if the module is initialized twice
0 commit comments