From d1a48527f707c36c3ee9c9833499bd45b44a5a53 Mon Sep 17 00:00:00 2001 From: Quino Terrasa Date: Tue, 27 Oct 2026 01:59:31 +0100 Subject: [PATCH 1/4] fix(platform): match CPython 3.14 platform.platform() output (#713) CPython's platform.platform() is not a raw uname triple. On macOS it is "macOS-----Mach-O"; on glibc Linux it appends "-with-glibc". ps_platform_platform formatted "%s-%s-%s", so the host batch of the call-table sweep diverged on this row. Rewrite it per platform: the macOS shape with the Mach-O ABI suffix, the glibc suffix via gnu_get_libc_version(), and the plain triple elsewhere (musl, WASI). Windows keeps its existing stand-in. Closes #713 --- src/pyscriptc/runtime/ps_osmore.c | 35 +++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/pyscriptc/runtime/ps_osmore.c b/src/pyscriptc/runtime/ps_osmore.c index 47ede241..8bc35b4e 100644 --- a/src/pyscriptc/runtime/ps_osmore.c +++ b/src/pyscriptc/runtime/ps_osmore.c @@ -25,6 +25,10 @@ are not searched. as_file of one of these paths is the path itself. #include #endif +#if defined(__linux__) && defined(__GLIBC__) +#include +#endif + #ifdef __APPLE__ #include #endif @@ -103,10 +107,10 @@ static int ps_temp_ready = 0; static pthread_mutex_t ps_temp_lock = PTHREAD_MUTEX_INITIALIZER; /* CPython runs every tempdir candidate through os.path.abspath before it -tests it, and abspath normalizes: a trailing slash goes away and a relative -path is joined to the cwd. macOS launchd sets TMPDIR with a trailing slash -(".../T/"), so returning the raw value would not match CPython's gettempdir. -ps_path_abs is the same normalization the posixpath surface uses. */ + tests it, and abspath normalizes: a trailing slash goes away and a relative + path is joined to the cwd. macOS launchd sets TMPDIR with a trailing slash + (".../T/"), so returning the raw value would not match CPython's gettempdir. + ps_path_abs is the same normalization the posixpath surface uses. */ static void ps_temp_abspath(const char *dir, char *out, size_t cap) { PsBuf abs; ps_path_abs((int64_t)strlen(dir), dir, &abs); @@ -944,9 +948,32 @@ void ps_platform_python_version(PsBuf *out) { ps_buf_copy(out, "3.14.9", 6); } +/* CPython 3.14 shapes: macOS is "macOS---- + -Mach-O"; glibc Linux appends "-with-glibc". Other targets + keep the plain uname triple. */ void ps_platform_platform(PsBuf *out) { #if defined(_WIN32) ps_buf_copy(out, "Windows", 7); +#elif defined(__APPLE__) + struct utsname u; + if (uname(&u) == 0) { + char buf[256]; + const char *processor = u.processor[0] != '\0' ? u.processor : u.machine; + const char *bits = sizeof(void *) == 8 ? "64bit" : "32bit"; + snprintf(buf, sizeof(buf), "macOS-%s-%s-%s-%s-Mach-O", u.release, u.machine, processor, bits); + ps_buf_copy(out, buf, (int64_t)strlen(buf)); + } else { + ps_buf_copy(out, "", 0); + } +#elif defined(__linux__) && defined(__GLIBC__) + struct utsname u; + if (uname(&u) == 0) { + char buf[256]; + snprintf(buf, sizeof(buf), "%s-%s-%s-with-glibc%s", u.sysname, u.release, u.machine, gnu_get_libc_version()); + ps_buf_copy(out, buf, (int64_t)strlen(buf)); + } else { + ps_buf_copy(out, "", 0); + } #else struct utsname u; if (uname(&u) == 0) { From da212eb70a6307b70c9027d0914a10330b902be3 Mon Sep 17 00:00:00 2001 From: Quino Terrasa Date: Tue, 27 Oct 2026 02:15:49 +0100 Subject: [PATCH 2/4] test(call-table): drop the #712/#713 divergence references (#713) The unicodedata.mirrored row is fixed by #712 (stacked under this PR) and platform.platform is fixed by this PR, so both probes now run clean and only the #714 realpath divergence reference remains. --- tests/test_stdlib_call_table.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_stdlib_call_table.py b/tests/test_stdlib_call_table.py index 72d1fb26..feff4d45 100644 --- a/tests/test_stdlib_call_table.py +++ b/tests/test_stdlib_call_table.py @@ -36,7 +36,6 @@ # a real difference from CPython 3.14 tracked as an issue; the entry is what # makes the batch an xfail instead of a failure, and it must be removed when # the row is fixed (the batch then passes on its own). -PLATFORM_DIVERGENCE = "issue #713 (platform.platform output)" REALPATH_DIVERGENCE = "issue #714 (os.path.realpath on a missing target)" @@ -390,7 +389,7 @@ def _p(module: str, member: str, group: str, *lines: str, divergence: str | None "host", "print(platform.python_version().startswith('3.14.'))", ), - _p("platform", "platform", "host", "print(platform.platform())", divergence=PLATFORM_DIVERGENCE), + _p("platform", "platform", "host", "print(platform.platform())"), _p("sys", "stdout.write", "host", "print(sys.stdout.write('dt') == 2)"), _p("sys", "stderr.write", "host", "print(sys.stderr.write('dt') == 2)"), _p("socket", "gethostname", "host", "print(len(socket.gethostname()) > 0)"), From 82de31fa81398180467aa65adc4e5241ef62392c Mon Sep 17 00:00:00 2001 From: Quino Terrasa <26749475+espetro@users.noreply.github.com> Date: Tue, 27 Oct 2026 01:25:16 -0700 Subject: [PATCH 3/4] fix(platform): macOS uses the product version and arm/i386 processor, not utsname.processor (#713) --- src/pyscriptc/runtime/ps_osmore.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pyscriptc/runtime/ps_osmore.c b/src/pyscriptc/runtime/ps_osmore.c index 8bc35b4e..841cade7 100644 --- a/src/pyscriptc/runtime/ps_osmore.c +++ b/src/pyscriptc/runtime/ps_osmore.c @@ -31,6 +31,7 @@ are not searched. as_file of one of these paths is the path itself. #ifdef __APPLE__ #include +#include #endif #ifdef __linux__ @@ -958,9 +959,14 @@ void ps_platform_platform(PsBuf *out) { struct utsname u; if (uname(&u) == 0) { char buf[256]; - const char *processor = u.processor[0] != '\0' ? u.processor : u.machine; + char product[64]; + size_t plen = sizeof(product); + /* CPython reports the product version (mac_ver), not the Darwin + release, and "arm" or "i386" for the processor. */ + const char *release = sysctlbyname("kern.osproductversion", product, &plen, NULL, 0) == 0 ? product : u.release; + const char *processor = strcmp(u.machine, "arm64") == 0 ? "arm" : (strcmp(u.machine, "x86_64") == 0 ? "i386" : u.machine); const char *bits = sizeof(void *) == 8 ? "64bit" : "32bit"; - snprintf(buf, sizeof(buf), "macOS-%s-%s-%s-%s-Mach-O", u.release, u.machine, processor, bits); + snprintf(buf, sizeof(buf), "macOS-%s-%s-%s-%s-Mach-O", release, u.machine, processor, bits); ps_buf_copy(out, buf, (int64_t)strlen(buf)); } else { ps_buf_copy(out, "", 0); From 9233f9058ddd8cffd962116b8c894e0adf0b4aa2 Mon Sep 17 00:00:00 2001 From: Quino Terrasa <26749475+espetro@users.noreply.github.com> Date: Tue, 27 Oct 2026 01:42:53 -0700 Subject: [PATCH 4/4] chore(compat2): regenerate IR_HASHES on Linux after the collector surface lowerings (A/B byte-identical) --- benchmarks/compat2/probes/IR_HASHES.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/compat2/probes/IR_HASHES.json b/benchmarks/compat2/probes/IR_HASHES.json index 37760b39..87df21e6 100644 --- a/benchmarks/compat2/probes/IR_HASHES.json +++ b/benchmarks/compat2/probes/IR_HASHES.json @@ -12964,7 +12964,7 @@ "stdlib.unicodedata.east_asian_width": "6ec948e62c433a9ddc05d7bef77a2ba3edf8b7c6c0009aef466040c102f89907", "stdlib.unicodedata.is_normalized": "fee9b71a96e634c7983077889f248575c03dd27d0ee45d8a95470980960267fe", "stdlib.unicodedata.lookup": "256b21d78885c2054e0b6db8f39a2094b93c4d88d9a5c478a5312e6a2ee63e5f", - "stdlib.unicodedata.mirrored": "ec2686bf4a1d417adfeff566c72b3d285d5f54aefc6c14102786b19268837e93", + "stdlib.unicodedata.mirrored": "5f5c5472d9aa0a53bbd092a30933bf7fb1e68c350540e08021d253dfde338307", "stdlib.unicodedata.name": "9cc866afaae198cc2e2d2e80cf0f371f7d7126709638fa79fe38327f50fbbc4d", "stdlib.unicodedata.normalize": "032eae258b7e27c3f1490f7aace0b5185d4b1a0e0cd600234ada0dc2e38841b2", "stdlib.unicodedata.numeric": "cd61fbee1099b191303e15d491567cc71f28d298886da9b64ec3792c4865f7df",