Skip to content

Commit 1719a26

Browse files
committed
pythongh-95853: Address wasm build and test issues
- pyexpat.c: readinst(): Use correct format char for int. - Add workaround for Emscripten timezone issue with calculating tm_yday. - Skip a decimal test that allocates a lot of memory. It sometimes fails on Emscripten.
1 parent 32ac98e commit 1719a26

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

Lib/test/test_decimal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
requires_legacy_unicode_capi, check_sanitizer)
3838
from test.support import (TestFailed,
3939
run_with_locale, cpython_only,
40-
darwin_malloc_err_warning)
40+
darwin_malloc_err_warning, is_emscripten)
4141
from test.support.import_helper import import_fresh_module
4242
from test.support import threading_helper
4343
from test.support import warnings_helper
@@ -5605,6 +5605,7 @@ def __abs__(self):
56055605
# Issue 41540:
56065606
@unittest.skipIf(sys.platform.startswith("aix"),
56075607
"AIX: default ulimit: test is flaky because of extreme over-allocation")
5608+
@unittest.skipIf(is_emscripten, "Test is unstable on Emscripten")
56085609
@unittest.skipIf(check_sanitizer(address=True, memory=True),
56095610
"ASAN/MSAN sanitizer defaults to crashing "
56105611
"instead of returning NULL for malloc failure.")

Modules/pyexpat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ readinst(char *buf, int buf_size, PyObject *meth)
775775
Py_ssize_t len;
776776
const char *ptr;
777777

778-
str = PyObject_CallFunction(meth, "n", buf_size);
778+
str = PyObject_CallFunction(meth, "i", buf_size);
779779
if (str == NULL)
780780
goto error;
781781

Tools/wasm/wasm_build.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ def _check_emscripten():
191191
config_site=WASMTOOLS / "config.site-wasm32-emscripten",
192192
configure_wrapper=EMSCRIPTEN_ROOT / "emconfigure",
193193
make_wrapper=EMSCRIPTEN_ROOT / "emmake",
194-
environ={"EM_COMPILER_WRAPPER": "ccache"} if HAS_CCACHE else {},
194+
environ={
195+
# workaround for https://github.com/emscripten-core/emscripten/issues/17635
196+
"TZ": "UTC",
197+
"EM_COMPILER_WRAPPER": "ccache" if HAS_CCACHE else None,
198+
},
195199
check=_check_emscripten,
196200
)
197201

@@ -352,12 +356,15 @@ def getenv(self) -> dict:
352356
env.setdefault("MAKEFLAGS", f"-j{os.cpu_count()}")
353357
platenv = self.host.platform.getenv(self)
354358
for key, value in platenv.items():
355-
if isinstance(value, str):
356-
value = value.format(
359+
if value is None:
360+
env.pop(key, None)
361+
elif isinstance(value, str):
362+
env[key] = value.format(
357363
relbuilddir=self.builddir.relative_to(SRCDIR),
358364
srcdir=SRCDIR,
359365
)
360-
env[key] = value
366+
else:
367+
env[key] = value
361368
return env
362369

363370
def _run_cmd(self, cmd: Iterable[str], args: Iterable[str]):

0 commit comments

Comments
 (0)