File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 16
16
imp = warnings_helper .import_deprecated ('imp' )
17
17
import _imp
18
18
import _testinternalcapi
19
- import _xxsubinterpreters as _interpreters
19
+ try :
20
+ import _xxsubinterpreters as _interpreters
21
+ except ModuleNotFoundError :
22
+ _interpreters = None
20
23
21
24
22
25
OS_PATH_NAME = os .path .__name__
23
26
24
27
28
+ def requires_subinterpreters (meth ):
29
+ """Decorator to skip a test if subinterpreters are not supported."""
30
+ return unittest .skipIf (_interpreters is None ,
31
+ 'subinterpreters required' )(meth )
32
+
33
+
25
34
def requires_load_dynamic (meth ):
26
35
"""Decorator to skip a test if not running under CPython or lacking
27
36
imp.load_dynamic()."""
@@ -254,6 +263,7 @@ def test_issue16421_multiple_modules_in_one_dll(self):
254
263
with self .assertRaises (ImportError ):
255
264
imp .load_dynamic ('nonexistent' , pathname )
256
265
266
+ @requires_subinterpreters
257
267
@requires_load_dynamic
258
268
def test_singlephase_multiple_interpreters (self ):
259
269
# Currently, for every single-phrase init module loaded
Original file line number Diff line number Diff line change @@ -197,13 +197,15 @@ gilstate_tss_clear(_PyRuntimeState *runtime)
197
197
}
198
198
199
199
200
+ #ifndef NDEBUG
200
201
static inline int tstate_is_alive (PyThreadState * tstate );
201
202
202
203
static inline int
203
204
tstate_is_bound (PyThreadState * tstate )
204
205
{
205
206
return tstate -> _status .bound && !tstate -> _status .unbound ;
206
207
}
208
+ #endif // !NDEBUG
207
209
208
210
static void bind_gilstate_tstate (PyThreadState * );
209
211
static void unbind_gilstate_tstate (PyThreadState * );
@@ -1119,6 +1121,7 @@ _PyInterpreterState_LookUpID(int64_t requested_id)
1119
1121
/* the per-thread runtime state */
1120
1122
/********************************/
1121
1123
1124
+ #ifndef NDEBUG
1122
1125
static inline int
1123
1126
tstate_is_alive (PyThreadState * tstate )
1124
1127
{
@@ -1127,6 +1130,7 @@ tstate_is_alive(PyThreadState *tstate)
1127
1130
!tstate -> _status .cleared &&
1128
1131
!tstate -> _status .finalizing );
1129
1132
}
1133
+ #endif
1130
1134
1131
1135
1132
1136
//----------
You can’t perform that action at this time.
0 commit comments