gen_d3d12_stubs: preserve multiline comment breaks, reject empty paths, and write atomically (GEN-D3D12-STUBS-COMMENTS-AND-IO) #1583

Merged
IlyassRS3 merged 1 commit from upstream-pr/1583 into main 2026-11-28 10:55:26 +00:00
IlyassRS3 commented 2026-11-25 05:08:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T05:08:43Z.


Item: GEN-D3D12-STUBS-COMMENTS-AND-IO (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/gen_d3d12_stubs.py).

Summary

  • Preserve line breaks when stripping multiline /* ... */ block comments in parse_interfaces(), preventing adjacent declarations or preprocessor directives after */ from merging into a single malformed method signature.
  • Reject empty or whitespace-only --out, --report, and --header arguments instead of silently ignoring "", falling back to INCLUDE on --header "", or creating whitespace-named files in cwd.
  • Make write_if_changed() read with newline="" (so stale CRLF files are rewritten to LF) and stage writes atomically via file_mode.published_mode + replace_retry.replace (preserving existing files on failure and keeping direct writes for non-regular targets), with strict JSON (allow_nan=False).
  • Catch OSError when reading --header or --source files in main(argv=None) and return a clean one-line ERROR: with exit code 2 instead of a raw traceback.

Verification

  • python3 -W error -I tests/test_gen_d3d12_stubs.py -v: 49 passed, 1 skipped (Windows-only case-fold test).
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/gen_d3d12_stubs.py tests/test_gen_d3d12_stubs.py: passed.
  • python3 -m compileall -q tools/gen_d3d12_stubs.py tests/test_gen_d3d12_stubs.py: passed.
  • Mutation check (running the new test suite against unpatched main:tools/gen_d3d12_stubs.py): failures=9, errors=1 across all 5 new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python build tool; synthetic headers only, no game data)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5485545972 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1583). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T05:08:43Z. --- Item: `GEN-D3D12-STUBS-COMMENTS-AND-IO` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/gen_d3d12_stubs.py`). ### Summary - Preserve line breaks when stripping multiline `/* ... */` block comments in `parse_interfaces()`, preventing adjacent declarations or preprocessor directives after `*/` from merging into a single malformed method signature. - Reject empty or whitespace-only `--out`, `--report`, and `--header` arguments instead of silently ignoring `""`, falling back to `INCLUDE` on `--header ""`, or creating whitespace-named files in `cwd`. - Make `write_if_changed()` read with `newline=""` (so stale CRLF files are rewritten to LF) and stage writes atomically via `file_mode.published_mode` + `replace_retry.replace` (preserving existing files on failure and keeping direct writes for non-regular targets), with strict JSON (`allow_nan=False`). - Catch `OSError` when reading `--header` or `--source` files in `main(argv=None)` and return a clean one-line `ERROR:` with exit code 2 instead of a raw traceback. ### Verification - `python3 -W error -I tests/test_gen_d3d12_stubs.py -v`: 49 passed, 1 skipped (Windows-only case-fold test). - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/gen_d3d12_stubs.py tests/test_gen_d3d12_stubs.py`: passed. - `python3 -m compileall -q tools/gen_d3d12_stubs.py tests/test_gen_d3d12_stubs.py`: passed. - Mutation check (running the new test suite against unpatched `main:tools/gen_d3d12_stubs.py`): `failures=9, errors=1` across all 5 new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python build tool; synthetic headers only, no game data)
copilot-pull-request-reviewer[bot] commented 2026-11-25 05:08:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T05:08:53Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6052151418 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1583#pullrequestreview-6052151418). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T05:08:53Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
MoonEyes commented 2026-11-28 10:55:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T10:55:22Z.


Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 19 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238209183 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1583#issuecomment-7238209183). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T10:55:22Z. --- Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18). Targeted batch of 19 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13. AI-assisted (Claude Code, Claude Opus 5.5)
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!1583
No description provided.