dev: accept argv, guard stdout.reconfigure, and reject whitespace --out #2278
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2278"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-26T12:16:35Z.
Claimed in the coordination issue as: DEV-CLI-STDOUT-RECONFIGURE-AND-ARGV-SAFETY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7191757339)
What and why
scripts/dev.pypreviously:main()with noargvparameter, preventing programmatic or in-process testing.sys.stdout.reconfigure(encoding="utf-8")unguarded indiscover, raisingAttributeErrorwhensys.stdoutis replaced withio.StringIOor another non-reconfigurable stream.--out " "as a valid--out PATHinguest-scene.This adds
argv: list[str] | None = Nonetomain(), wrapssys.stdout.reconfigure(encoding="utf-8")intry/except (AttributeError, ValueError, OSError), rejects whitespace-only--outinguest_scene(), and adds unit tests intests/test_dev_discovery.py.Tested
python -I tests/test_dev_discovery.py -v(5 passed)python -I tests/test_dev_guest_scene.py -v(4 passed)upstream/mainbaseline negative control: failed withtests/test_dev_discovery.pybefore the fixpython -I tests/test_ci_registration.py,python -I tests/test_text_write_line_endings.py,python -I scripts/check_no_game_data.py,python -I -m compileall -q, andgit diff --cached --checkGPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-26T12:51:53Z.
Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
tests/test_dev_discovery.py: 5 passed, 2 subtests passed (main: 4 passed).(AI-assisted test run; output checked by hand.)
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T04:38:50Z.
Review: APPROVED
Approving
0da952685.A blank
--outis refused,maintakes argv for tests, andsys.stdout.reconfigurefailing (a replaced or detached stdout) no longer ends the run.Merged onto
maind1dff7949in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13.tests/test_dev_discovery.py: 5 passed (main: 4). AI-assisted (Claude Code, Claude Opus 5.5).Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T19:33:18Z.
Red/green: tests/test_dev_discovery.py errors on main (TypeError: main() takes 0 positional arguments) and passes with the PR merged, on GitHub Actions Linux and natively on Windows.
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
7daa4a4a5in GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)