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

Merged
fiestorra merged 1 commit from upstream-pr/2827 into main 2026-12-01 04:09:48 +00:00
fiestorra commented 2026-12-01 03:53:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-01T03:53:46Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5578650180 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2827). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-01T03:53:46Z. --- **`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:** ```python 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.
OreoFR commented 2026-12-01 03:57:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T03:57:53Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7300239792 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2827#issuecomment-7300239792). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-01T03:57:53Z. --- **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 commented 2026-12-01 04:09:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T04:09:54Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7300445105 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2827#issuecomment-7300445105). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-01T04:09:54Z. --- 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 commented 2026-12-01 04:11:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-01T04:11:48Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7300477860 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2827#issuecomment-7300477860). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-01T04:11:48Z. --- **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 in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2827
No description provided.