textures: report malformed --indices as a usage error in the batch exporter #1524
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1531"
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 R0Y00/Xbox2Windows. Originally posted by RenzoWit35 on 2026-11-24T13:43:29Z.
Change
tools/ttpf_batch_export.pycalledparse_indices(args.indices)inmain()outside thetryblock that turns other failures intoparser.error(...). A malformed--indicesvalue therefore ended in a raw Python traceback with exit code 1 instead of the tool's usage error (exit code 2).main()now catches theValueErrorfromparse_indicesand callsparser.error(f"--indices: {exc}"), matching the neighbouring failure handling._index_inthelper replaces the bareint()calls so a non-integer token givesInvalid index 'abc' in 'abc': expected an integerinstead of the Python-internalinvalid literal for int() with base 10: ''.Invalid range '5-3': start (5) > end (3)text are unchanged.Verification
Windows 11, Python 3.14.5, base
origin/main1ca0dec1.Before (unmodified
origin/main, empty file as pool,python -B tools/ttpf_batch_export.py empty.ttpf -o <dir> --indices "<v>"), all four exit 1 with a full traceback:5-3:ValueError: Invalid range '5-3': start (5) > end (3)1-:ValueError: invalid literal for int() with base 10: ''abc:ValueError: invalid literal for int() with base 10: 'abc'-2: argparse accepts it as the option value (it looks like a negative number), thenparse_indicessplits it on-and fails withinvalid literal for int() with base 10: ''. argparse behaviour is not changed.After (same commands), each exits 2 with a one-line message and no traceback:
ttpf_batch_export.py: error: --indices: Invalid range '5-3': start (5) > end (3)ttpf_batch_export.py: error: --indices: Invalid index '' in '1-': expected an integerttpf_batch_export.py: error: --indices: Invalid index 'abc' in 'abc': expected an integerttpf_batch_export.py: error: --indices: Invalid index '' in '-2': expected an integerNew test
test_malformed_indices_are_usage_errorsintests/ttpf_batch_export_check.pyruns the tool in a subprocess for the four values and asserts exit code 2, the--indices:message naming the bad token, noTraceback, and that no output directory is created. It also checksparse_indices("0-1,3") == [0, 1, 3]as a control.out/pe-env/Scripts/python.exe -B tests/ttpf_batch_export_check.py:Ran 12 tests ... OK (skipped=1)(the skip was already present).tools/ttpf_batch_export.pyrestored toorigin/main, the same command givesFAILED (failures=4, skipped=1), each1 != 2with a traceback in stderr.Not run: other test files. The test is already listed in
AGENTS.mdand the CI Python job, so no registration change was needed.Evidence and follow-up
Draft PR #836 (Rust batch exporter) also modifies
tools/ttpf_batch_export.py; the hunks here are small and inparse_indicesandmain(), so a textual conflict is possible but should be easy to resolve. No issue is linked.AI-assisted.