From 19bf135c18816c8c60e757f0e6b9247aa53e8024 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 26 Oct 2026 11:41:58 -0400 Subject: [PATCH 1/2] idna: AGENTS.md sends the reader to the superproject's coding guidelines The superproject's rules and design decisions moved to CODING-GUIDELINES.md, whose chapter 15 gives this library's decisions with their reasons; its AGENTS.md says how to work in the tree. Both are read before this file. --- AGENTS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index bffeb94..47b58f2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,9 @@ # Working on idna webcpp's rules apply here: read the superproject's +[CODING-GUIDELINES.md](../../CODING-GUIDELINES.md) +(), whose +chapter 15 gives idna's design decisions with their reasons, and its [AGENTS.md](../../AGENTS.md) () first. This file holds only what is specific to idna. From e324c908a1722990e045ae4e41cdb8ad5aec205e Mon Sep 17 00:00:00 2001 From: R Date: Tue, 27 Oct 2026 16:21:56 -0400 Subject: [PATCH 2/2] idna: writes each file of the Unicode cache through a partial file of its own Two generators that fill one cache at once, as the generated lane's tables and patterns do under b2 -j on a fresh CI runner, both downloaded a missing file and wrote it through the same .partial, so the second rename found nothing: lexical's lane failed on 'No such file or directory: ...DerivedCoreProperties.txt.partial'. Reproduced by calling write() from eight processes on one path: 1,200 of 1,600 writes failed before, none after. Each writer's partial file now has a name of its own, removed if the write fails, and the last rename wins with the same checked bytes. --- tools/generate_tables.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/generate_tables.py b/tools/generate_tables.py index b71e8bc..0f35c2b 100755 --- a/tools/generate_tables.py +++ b/tools/generate_tables.py @@ -55,6 +55,7 @@ import sys import textwrap import urllib.request +import uuid from collections.abc import Iterator, Sequence from pathlib import Path @@ -168,11 +169,17 @@ def pinned_files(pinned: Path) -> tuple[str, dict[str, dict[str, str]]]: def write(path: Path, data: bytes) -> None: - """Writes the data at the path through a sibling file, so that no reader sees half of it.""" + """Writes the data at the path through a sibling file of its own, so that no reader sees half + of it, and two writers of one path, such as two generators filling one cache at once, never + rename each other's file: the last to finish wins, with the same checked bytes.""" path.parent.mkdir(parents=True, exist_ok=True) - partial = path.with_name(path.name + '.partial') - partial.write_bytes(data) - partial.replace(path) + partial = path.with_name(f'{path.name}.{uuid.uuid4().hex}.partial') + try: + partial.write_bytes(data) + partial.replace(path) + except BaseException: + partial.unlink(missing_ok=True) + raise def checked(data: bytes, source: str, pinned: str) -> bytes: