Visitar URL original
gh-158996: Check that Emscripten free-threaded build works by hoodmane · Pull Request #158997 · python/cpython · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2964,6 +2964,7 @@ def func():


@unittest.skipUnless(support.Py_GIL_DISABLED, 'need Py_GIL_DISABLED')
@threading_helper.requires_working_threading()
class TestPyThreadId(unittest.TestCase):
def test_py_thread_id(self):
# gh-112535: Test _Py_ThreadId(): make sure that thread identifiers
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_warnings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from test.support import import_helper
from test.support import isolation
from test.support import os_helper
from test.support import threading_helper
from test.support import warnings_helper
from test.support import force_not_colorized
from test.support.script_helper import assert_python_ok, assert_python_failure
Expand Down Expand Up @@ -1806,6 +1807,7 @@ def test_late_resource_warning(self):
self.assertStartsWith(err, expected)


@support.requires_working_socket()
class AsyncTests(BaseTest):
"""Verifies that the catch_warnings() context manager behaves
as expected when used inside async co-routines. This requires
Expand Down Expand Up @@ -1900,6 +1902,7 @@ class PyAsyncTests(AsyncTests, unittest.TestCase):
module = py_warnings


@threading_helper.requires_working_threading()
class ThreadTests(BaseTest):
"""Verifies that the catch_warnings() context manager behaves as
expected when used within threads. This requires that both the
Expand Down
2 changes: 2 additions & 0 deletions Platforms/emscripten/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ def configure_emscripten_python(context, working_dir):
f"--with-build-python={build_python}",
"--without-pymalloc",
"--disable-shared",
"--disable-gil",
"--with-mimalloc",
"--disable-ipv6",
"--enable-big-digits=30",
"--enable-wasm-dynamic-linking",
Expand Down
23 changes: 8 additions & 15 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3844,7 +3844,7 @@ PyDoc_STRVAR(emscripten_info__doc__,
\n\
WebAssembly Emscripten platform information.");

static PyTypeObject *EmscriptenInfoType;
static PyTypeObject EmscriptenInfoType;

static PyStructSequence_Field emscripten_info_fields[] = {
{"emscripten_version", "Emscripten version (major, minor, micro)"},
Expand Down Expand Up @@ -3908,7 +3908,7 @@ make_emscripten_info(void)
char *ua;
int pos = 0;

emscripten_info = PyStructSequence_New(EmscriptenInfoType);
emscripten_info = PyStructSequence_New(&EmscriptenInfoType);
if (emscripten_info == NULL) {
return NULL;
}
Expand Down Expand Up @@ -4071,6 +4071,11 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
SET_SYS_FROM_STRING("_vpath", VPATH);
#endif

#ifdef __EMSCRIPTEN__
ENSURE_INFO_TYPE(EmscriptenInfoType, emscripten_info_desc);
SET_SYS("_emscripten_info", make_emscripten_info());
#endif

#undef ENSURE_INFO_TYPE

/* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */
Expand All @@ -4091,16 +4096,6 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
goto type_init_failed;
}

#ifdef __EMSCRIPTEN__
if (EmscriptenInfoType == NULL) {
EmscriptenInfoType = PyStructSequence_NewType(&emscripten_info_desc);
if (EmscriptenInfoType == NULL) {
goto type_init_failed;
}
}
SET_SYS("_emscripten_info", make_emscripten_info());
#endif

/* adding sys.path_hooks and sys.path_importer_cache */
SET_SYS("meta_path", PyList_New(0));
SET_SYS("path_importer_cache", PyDict_New());
Expand Down Expand Up @@ -4408,9 +4403,7 @@ _PySys_FiniTypes(PyInterpreterState *interp)
_PyStructSequence_FiniBuiltin(interp, &Hash_InfoType);
_PyStructSequence_FiniBuiltin(interp, &AsyncGenHooksType);
#ifdef __EMSCRIPTEN__
if (_Py_IsMainInterpreter(interp)) {
Py_CLEAR(EmscriptenInfoType);
}
_PyStructSequence_FiniBuiltin(interp, &EmscriptenInfoType);
#endif
}

Expand Down
Loading