Skip to content

Commit e39fd37

Browse files
committed
windows-msys: bare boot pins driver + getpath warnings, not exit status (round-9)
Run 34760958198's windows leg failed the bare scenario on its POSIX assertions: the child printed 'unreached' and exited 0, with only the driver warning and getpath's "Could not find platform independent libraries <prefix>" on stderr. Mechanism, established against the 3.14.7 sources: the encodings import at startup is unconditional (pylifecycle.c _PyUnicode_InitEncodings -> unicodeobject.c _PyCodec_InitRegistry, fatal on failure), so a child that ran user code necessarily FOUND a stdlib. The channel is upstream: Modules/getpath.py's winreg section (os_name == 'nt' and use_environment and winreg) appends the HKCU/HKLM SOFTWARE\Python\PythonCore\<ver>\PythonPath registry values to sys.path — and the GHA runner has a registered host python. Bare boot on windows is therefore environment-dependent by upstream design: exit status and the encodings fatal are not assertable there. The msys bare scenario now pins the deterministic surface instead: the driver's bare-boot warning (ours, every platform) plus getpath's platstdlib warning (the prefix fell back to the baked-in mount root, which never exists on the runner). POSIX keeps the strict trio (non-zero exit + driver warning + encodings fatal) — no registry fallback exists there.
1 parent 0dc372c commit e39fd37

1 file changed

Lines changed: 31 additions & 10 deletions

File tree

‎tools/boot_smoke‎

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
# stdlib is image-resident (the two-artifact
3636
# model), so the driver warns about the bare
3737
# boot and the interpreter fails on its own
38-
# terms (non-zero exit; every platform)
38+
# terms (non-zero exit + the encodings fatal on
39+
# POSIX; on windows upstream's winreg fallback
40+
# can hand the child a host-registered stdlib,
41+
# so only the driver's warning and getpath's
42+
# platstdlib warning are pinned there)
3943
# boot TEBAKO_RUNTIME_IMAGE handoff: stdlib imports
4044
# (json/zlib/ssl) off the mounted image, sys.prefix
4145
# == the mount root [POSIX]
@@ -341,18 +345,35 @@ def run_scenarios(executable, platform, selected, tfs:, line:) # rubocop:disable
341345
case scenario
342346
when "bare"
343347
# The two-artifact model: the exe alone is NOT a dev-mode
344-
# interpreter — the stdlib lives in the env image, so a bare
345-
# boot can only fail (getpath's compiled-in prefix resolves
346-
# empty and the encodings import dies). What this scenario pins
347-
# is the DRIVER's half of the contract: it names the bare boot
348-
# on stderr, then the interpreter fails on its own terms.
348+
# interpreter — the stdlib lives in the env image. What this
349+
# scenario pins on every platform is the DRIVER's half of the
350+
# contract: it names the bare boot on stderr.
349351
out, err, st = boot(executable, ["-c", "print('unreached')"], {})
350-
check("bare: non-zero exit (the stdlib is image-resident)",
351-
!st.nil? && !st.exitstatus&.zero?, "stdout: #{out}\nstderr: #{err}")
352352
check("bare: the driver names the bare boot",
353353
err.include?("TEBAKO_RUNTIME_IMAGE is not set"), "stderr: #{err}")
354-
check("bare: the interpreter ran and died on the missing stdlib",
355-
err.include?("encodings"), "stderr: #{err}")
354+
if platform.msys?
355+
# Windows startup is environment-dependent by upstream design:
356+
# Modules/getpath.py ("os_name == 'nt' and use_environment and
357+
# winreg") appends the HKCU/HKLM SOFTWARE\Python\PythonCore\<ver>\
358+
# PythonPath registry values to sys.path, so on a host with a
359+
# REGISTERED python (the GHA runner ships one) the child finds a
360+
# stdlib, imports encodings, and RUNS the -c program — observed on
361+
# the 0dc372c windows leg (run 34760958198): exit 0, 'unreached'
362+
# printed. On a registry-clean host it dies with the encodings
363+
# fatal like POSIX. Exit status and the encodings message are
364+
# therefore not assertable here; the deterministic upstream
365+
# surface is getpath's platstdlib warning (the prefix fell back
366+
# to the baked-in mount root, which never exists on the runner).
367+
check("bare: getpath names the missing platstdlib",
368+
err.include?("Could not find platform independent libraries"), "stderr: #{err}")
369+
else
370+
# POSIX: no registry fallback — getpath's compiled-in prefix
371+
# resolves empty and the encodings import dies at Py_Initialize.
372+
check("bare: non-zero exit (the stdlib is image-resident)",
373+
!st.nil? && !st.exitstatus&.zero?, "stdout: #{out}\nstderr: #{err}")
374+
check("bare: the interpreter ran and died on the missing stdlib",
375+
err.include?("encodings"), "stderr: #{err}")
376+
end
356377
when "boot"
357378
unless File.file?(image)
358379
check("boot", false, "no sibling env image #{image}")

0 commit comments

Comments
 (0)