]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-101758: Fix the wasm Buildbots (gh-101943)
authorEric Snow <ericsnowcurrently@gmail.com>
Thu, 16 Feb 2023 00:54:05 +0000 (17:54 -0700)
committerGitHub <noreply@github.com>
Thu, 16 Feb 2023 00:54:05 +0000 (17:54 -0700)
They were broken by gh-101920.

https://github.com/python/cpython/issues/101758

Lib/test/test_imp.py
Python/pystate.c

index e81eb6f0a86fe863b51ece94afc2d231a301232e..5997ffad8e1232082586e1637688786b456615c5 100644 (file)
@@ -16,12 +16,21 @@ import warnings
 imp = warnings_helper.import_deprecated('imp')
 import _imp
 import _testinternalcapi
-import _xxsubinterpreters as _interpreters
+try:
+    import _xxsubinterpreters as _interpreters
+except ModuleNotFoundError:
+    _interpreters = None
 
 
 OS_PATH_NAME = os.path.__name__
 
 
+def requires_subinterpreters(meth):
+    """Decorator to skip a test if subinterpreters are not supported."""
+    return unittest.skipIf(_interpreters is None,
+                           'subinterpreters required')(meth)
+
+
 def requires_load_dynamic(meth):
     """Decorator to skip a test if not running under CPython or lacking
     imp.load_dynamic()."""
@@ -254,6 +263,7 @@ class ImportTests(unittest.TestCase):
         with self.assertRaises(ImportError):
             imp.load_dynamic('nonexistent', pathname)
 
+    @requires_subinterpreters
     @requires_load_dynamic
     def test_singlephase_multiple_interpreters(self):
         # Currently, for every single-phrase init module loaded
index 4770caaed0a3631556b8cf2761f20e827039b75c..32b17fd19e348f462901d016c4469d439b06da1f 100644 (file)
@@ -197,6 +197,7 @@ gilstate_tss_clear(_PyRuntimeState *runtime)
 }
 
 
+#ifndef NDEBUG
 static inline int tstate_is_alive(PyThreadState *tstate);
 
 static inline int
@@ -204,6 +205,7 @@ tstate_is_bound(PyThreadState *tstate)
 {
     return tstate->_status.bound && !tstate->_status.unbound;
 }
+#endif  // !NDEBUG
 
 static void bind_gilstate_tstate(PyThreadState *);
 static void unbind_gilstate_tstate(PyThreadState *);
@@ -1119,6 +1121,7 @@ _PyInterpreterState_LookUpID(int64_t requested_id)
 /* the per-thread runtime state */
 /********************************/
 
+#ifndef NDEBUG
 static inline int
 tstate_is_alive(PyThreadState *tstate)
 {
@@ -1127,6 +1130,7 @@ tstate_is_alive(PyThreadState *tstate)
             !tstate->_status.cleared &&
             !tstate->_status.finalizing);
 }
+#endif
 
 
 //----------