Skip to content

Commit 16d4d2c

Browse files
authored
Merge branch 'main' into patch-1
2 parents c2aebbb + 580043d commit 16d4d2c

File tree

5 files changed

+56
-29
lines changed

5 files changed

+56
-29
lines changed

Doc/tools/extensions/c_annotations.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,27 +308,27 @@ def _unstable_api_annotation() -> nodes.admonition:
308308
def _threadsafety_annotation(level: str) -> nodes.emphasis:
309309
match level:
310310
case "incompatible":
311-
display = sphinx_gettext("Not safe to call from multiple threads.")
311+
display = sphinx_gettext("Not safe to call from multiple threads")
312312
reftarget = "threadsafety-level-incompatible"
313313
case "compatible":
314314
display = sphinx_gettext(
315315
"Safe to call from multiple threads"
316-
" with external synchronization only."
316+
" with external synchronization only"
317317
)
318318
reftarget = "threadsafety-level-compatible"
319319
case "distinct":
320320
display = sphinx_gettext(
321321
"Safe to call without external synchronization"
322-
" on distinct objects."
322+
" on distinct objects"
323323
)
324324
reftarget = "threadsafety-level-distinct"
325325
case "shared":
326326
display = sphinx_gettext(
327-
"Safe for concurrent use on the same object."
327+
"Safe for concurrent use on the same object"
328328
)
329329
reftarget = "threadsafety-level-shared"
330330
case "atomic":
331-
display = sphinx_gettext("Atomic.")
331+
display = sphinx_gettext("Atomic")
332332
reftarget = "threadsafety-level-atomic"
333333
case _:
334334
raise AssertionError(f"Unknown thread safety level {level!r}")
@@ -340,9 +340,11 @@ def _threadsafety_annotation(level: str) -> nodes.emphasis:
340340
reftype="ref",
341341
refexplicit="True",
342342
)
343-
prefix = sphinx_gettext("Thread safety:") + " "
343+
prefix = " " + sphinx_gettext("Thread safety:") + " "
344344
classes = ["threadsafety", f"threadsafety-{level}"]
345-
return nodes.emphasis("", prefix, ref_node, classes=classes)
345+
return nodes.emphasis(
346+
"", prefix, ref_node, nodes.Text("."), classes=classes
347+
)
346348

347349

348350
def _return_value_annotation(result_refs: int | None) -> nodes.emphasis:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a bug in :func:`termios.tcsetwinsize` where passing a sequence that
2+
raises an exception in ``__getitem__`` would cause a :exc:`SystemError`
3+
instead of propagating the original exception.

Modules/termios.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,19 +500,24 @@ termios_tcsetwinsize_impl(PyObject *module, int fd, PyObject *winsz)
500500
PyObject *tmp_item;
501501
long winsz_0, winsz_1;
502502
tmp_item = PySequence_GetItem(winsz, 0);
503+
if (tmp_item == NULL) {
504+
return NULL;
505+
}
503506
winsz_0 = PyLong_AsLong(tmp_item);
507+
Py_DECREF(tmp_item);
504508
if (winsz_0 == -1 && PyErr_Occurred()) {
505-
Py_XDECREF(tmp_item);
506509
return NULL;
507510
}
508-
Py_XDECREF(tmp_item);
509511
tmp_item = PySequence_GetItem(winsz, 1);
512+
if (tmp_item == NULL) {
513+
return NULL;
514+
}
510515
winsz_1 = PyLong_AsLong(tmp_item);
516+
Py_DECREF(tmp_item);
511517
if (winsz_1 == -1 && PyErr_Occurred()) {
512-
Py_XDECREF(tmp_item);
513518
return NULL;
514519
}
515-
Py_XDECREF(tmp_item);
520+
516521

517522
termiosmodulestate *state = PyModule_GetState(module);
518523

Platforms/emscripten/__main__.py

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,41 @@ def make_mpdec(context, working_dir):
413413
write_library_config(prefix, "mpdec", mpdec_config, context.quiet)
414414

415415

416+
def calculate_node_path():
417+
node_version = os.environ.get("PYTHON_NODE_VERSION", None)
418+
if node_version is None:
419+
node_version = load_config_toml()["node-version"]
420+
421+
subprocess.run(
422+
[
423+
"bash",
424+
"-c",
425+
f"source ~/.nvm/nvm.sh && nvm install {node_version}",
426+
],
427+
check=True,
428+
)
429+
430+
res = subprocess.run(
431+
[
432+
"bash",
433+
"-c",
434+
f"source ~/.nvm/nvm.sh && nvm which {node_version}",
435+
],
436+
text=True,
437+
capture_output=True,
438+
check=True,
439+
)
440+
return res.stdout.strip()
441+
442+
416443
@subdir("host_dir", clean_ok=True)
417444
def configure_emscripten_python(context, working_dir):
418445
"""Configure the emscripten/host build."""
419446
validate_emsdk_version(context.emsdk_cache)
447+
host_runner = context.host_runner
448+
if host_runner is None:
449+
host_runner = calculate_node_path()
450+
420451
paths = context.build_paths
421452
config_site = os.fsdecode(EMSCRIPTEN_DIR / "config.site-wasm32-emscripten")
422453

@@ -435,19 +466,6 @@ def configure_emscripten_python(context, working_dir):
435466
)
436467
if pydebug:
437468
sysconfig_data += "-pydebug"
438-
439-
host_runner = context.host_runner
440-
if node_version := os.environ.get("PYTHON_NODE_VERSION", None):
441-
res = subprocess.run(
442-
[
443-
"bash",
444-
"-c",
445-
f"source ~/.nvm/nvm.sh && nvm which {node_version}",
446-
],
447-
text=True,
448-
capture_output=True,
449-
)
450-
host_runner = res.stdout.strip()
451469
pkg_config_path_dir = (paths["prefix_dir"] / "lib/pkgconfig/").resolve()
452470
env_additions = {
453471
"CONFIG_SITE": config_site,
@@ -613,8 +631,6 @@ def add_cross_build_dir_option(subcommand):
613631

614632

615633
def main():
616-
default_host_runner = "node"
617-
618634
parser = argparse.ArgumentParser()
619635
subcommands = parser.add_subparsers(dest="subcommand")
620636

@@ -744,10 +760,10 @@ def main():
744760
subcommand.add_argument(
745761
"--host-runner",
746762
action="store",
747-
default=default_host_runner,
763+
default=None,
748764
dest="host_runner",
749-
help="Command template for running the emscripten host"
750-
f"`{default_host_runner}`)",
765+
help="Command template for running the emscripten host "
766+
"(default: use nvm to install the node version specified in config.toml)",
751767
)
752768

753769
context = parser.parse_args()

Platforms/emscripten/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# This allows for blanket copying of the Emscripten build code between supported
33
# Python versions.
44
emscripten-version = "4.0.12"
5+
node-version = "24"
56

67
[libffi]
78
url = "https://github.com/libffi/libffi/releases/download/v{version}/libffi-{version}.tar.gz"

0 commit comments

Comments
 (0)