Skip to content

tools: make_amplify_dxil writes '?' for what a redirected stdout cannot encode - #2827

Merged
OreoFR merged 1 commit into
ProjectLeonida:mainfrom
fiestorra:fix-amplify-stdout
Dec 1, 2026
Merged

OreoFR merged 1 commit into
ProjectLeonida:mainfrom
fiestorra:fix-amplify-stdout

Conversation

@fiestorra

Copy link
Copy Markdown
Contributor

main 023043bfe fails tests/test_tool_stdout_encoding.py, on both Linux and Windows, because the tool that landed with it does not do what every other tool in tools/ does. Four lines, the same block as its neighbours.

Seen first on a pull request that has nothing to do with it - #2825 removes a Rust module declaration, and linux-python-and-viewer came back red. So I ran it on main with nothing applied:

python -m pytest tests/test_tool_stdout_encoding.py -q
  1 failed, 3 passed, 2 subtests passed   (main 023043bfe, nothing applied)

  AssertionError: Lists differ: ['tools/make_amplify_dxil.py'] != []
  programs whose __main__ block doesn't set errors='replace' on stdout

And in CI, in both jobs:

check                    ##[error]tests/test_tool_stdout_encoding.py failed   631 files, 1 files failed
linux-python-and-viewer  ##[error]tests/test_tool_stdout_encoding.py failed   631 files, 1 files failed

So it is not flaky and not platform-specific: it is the repository's own convention test doing its job on a file that arrived without the convention.

The change:

if __name__ == "__main__":
    try:  # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode
        sys.stdout.reconfigure(errors="replace")
    except (AttributeError, ValueError, OSError):
        pass
    main()

Copied from ab_control_flow.py, which has the same block with the same comment - address_guard.py, amd_swizzle.py and the rest have it too.

Verified:

python -m pytest tests/test_tool_stdout_encoding.py -q
  4 passed, 2 subtests passed

What this does not fix: the tool still cannot encode a character its code page lacks - it now writes ? instead of raising. That is exactly what the other tools do and what the test asks for; whether make_amplify_dxil.py should print anything that a code page cannot encode is a different question, and it prints paths and DXC's output.

AI-assisted: yes - DeepSeek v4.1 (flash), which found it by chasing a red that was not its own.

Written with an AI assistant.

…ot encode

test_tool_stdout_encoding.py requires every tool's __main__ to set errors='replace'
on stdout, for a redirected stdout that is a strict ANSI code page under -I. The new
tool did not, so main failed that test on both Linux and Windows.

Same block as ab_control_flow.py and the other tools.
@OreoFR

OreoFR commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Verified (not the author). AI-assisted (Claude Code agent oreofr-agent, for OreoFR). Windows 11 Pro, Python 3.12, python -I.

Head 1d7212e64 merged into the current main 9d231d373 (clean, 4 lines in tools/make_amplify_dxil.py; sys is already imported there).

  • Red, plain main 9d231d373: python -I tests/test_tool_stdout_encoding.py → Ran 4 tests, FAILED (failures=1) (['tools/make_amplify_dxil.py'] != []).
  • Green, main + this PR: Ran 4 tests, OK.
  • The block is the same reconfigure(errors="replace") guard the other tools use, before main(); nothing else in the tool changes. check_no_game_data.py on the file: exit 0.

With #2825 (the missing asbench module), this clears the two reds that check and linux-python-and-viewer show on every branch based on main today. The third red, xtask's repository_passes_policy (two large .rs files, handled by #2815, and the embedded DXIL in indirect/amplify_dxil.rs, handled by nothing yet), is not in the GitHub CI.

@OreoFR
OreoFR merged commit 86c30fc into ProjectLeonida:main Dec 1, 2026
5 checks passed
@OreoFR

OreoFR commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Merging. Head 1d7212e64 merges cleanly with main 957fa9fe7.
Claim: none in the description; this is the fix of a red on main (tests/test_tool_stdout_encoding.py on tools/make_amplify_dxil.py, red on check and linux-python-and-viewer since 3b8b040c3), merged under the exception for fixes of a red on main with a human maintainer other than its author agreeing: OreoFR agreed in writing (agents' bridge thread, "Oui").
Red/green: by oreofr-agent (not the author), Windows 11, Python 3.12, python -I tests/test_tool_stdout_encoding.py: FAILED (failures=1) on plain main 957fa9fe7, OK with this head merged into it (and the same on 9d231d373).
In-game run: not needed, because the change is a tool's __main__ block that neither the build nor a run of the game uses.
CI: green on the head (all 5 checks); with #2825 merged before it, this clears main's GitHub CI red.
AI-assisted: yes, Claude Code agent oreofr-agent, merged on OreoFR's (maintainer) written instruction.

@fiestorra

Copy link
Copy Markdown
Contributor Author

Superseded by the combined pull request if you prefer one merge: both reds (mod asbench and this tool's __main__) are in it together, because separately each inherits the other's red from main and neither can show green. Either way the changes are identical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants