[Python-checkins] gh-101758: Fix the wasm Buildbots (gh-101943)

ericsnowcurrently webhook-mailer at python.org
Wed Feb 15 19:54:12 EST 2023


https://github.com/python/cpython/commit/3dea4ba6c1b9237893d23574f931f33c940b74e8
commit: 3dea4ba6c1b9237893d23574f931f33c940b74e8
branch: main
author: Eric Snow <ericsnowcurrently at gmail.com>
committer: ericsnowcurrently <ericsnowcurrently at gmail.com>
date: 2023-02-15T17:54:05-07:00
summary:

gh-101758: Fix the wasm Buildbots (gh-101943)

They were broken by gh-101920.

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

files:
M Lib/test/test_imp.py
M Python/pystate.c

diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index e81eb6f0a86f..5997ffad8e12 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -16,12 +16,21 @@
 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 @@ def test_issue16421_multiple_modules_in_one_dll(self):
         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
diff --git a/Python/pystate.c b/Python/pystate.c
index 4770caaed0a3..32b17fd19e34 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -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
 
 
 //----------



More information about the Python-checkins mailing list