tools/bcpack_tables_bptc.py: harden integer/key validation and class/bit-depth bounds #2285
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2285"
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:45:15Z.
Claimed in the coordination issue as: BCPACK-BPTC-STRICT-INT-VALIDATION-AND-BIT-BOUNDS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7192331643)
What and why
_strict_int()intools/bcpack_tables_bptc.pyto rejectboolandfloatvalues (and non-integer strings) while preserving plain integer and ASCII integer string parsing._iter_entries()for dictionary tables to rejectbool,float, whitespace/signed/non-ASCII-digit keys, and duplicate resolved indices (such as"01"colliding with"1").endpointClassandindexClassvalues within0..3inload_bc6h().load_bc7(): non-negativehistoryEndpointBits(preserving>= 8full-precision handling),0..8forhistoryEndpointConfirmedBits, and0..4forhistoryIndexBits/historyIndexConfirmedBits.tests/test_bcpack_tables_bptc.py.Tested
python -I tests/test_bcpack_tables_bptc.py -v: 29 passed, 0 failed (detachedupstream/mainbaseline with only the updated test file fails with 17 failures).python -I tests/test_ci_registration.py: 16 passed.python -I tests/test_text_write_line_endings.py: 3 passed.python -I scripts/check_no_game_data.py,python -I -m compileall -q tools/bcpack_tables_bptc.py tests/test_bcpack_tables_bptc.py, andgit diff --cached --check: passed.GPUs 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 tiguan26 on 2026-11-27T04:39:27Z.
Review: APPROVED
Approving
74bd28ac7.The history loader takes integers strictly (no bools, floats or stray strings), refuses duplicate entry indexes, and bounds the endpoint and index classes (0..3) and the BC7 bit depths. Since
gen_bcpack_runtime_tables.pybuilds the runtime's tables through this loader, I generated them on this batch and onmain: the output is byte-for-byte identical, so the stricter checks accept the shipped history.Merged onto
maind1dff7949in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13.tests/test_bcpack_tables_bptc.py: 29 passed (main: 27). AI-assisted (Claude Code, Claude Opus 5.5).Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T10:35:08Z.
#2285 | head
74bd28ac71(merged cleanly with main6c7f79343) |python -I tests/test_bcpack_tables_bptc.py| red on main:FAILED (failures=17)(bool, float, non-ASCII digit, and"01"vs"1"duplicate history keys accepted, plus out-of-range BC6H class and BC7 bit-depth values not rejected) | green on PR+main:29 tests OK| Windows 11, Python 3.12.10 | AI-assisted: yesAudited
_strict_int,_iter_entries(ASCII digit-only string keys + duplicate index rejection),load_bc6h(endpointClass/indexClass0..3bounds),load_bc7(bit-depth bounds andhistoryEndpointLastResortstrict ints), andload_bc_historyintools/bcpack_tables_bptc.py. Also verified0merge conflicts against #2512 and passedtests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK),tests/test_runner_calls_all_tests.py(3 OK), andscripts/check_no_game_data.py.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T15:09:38Z.
Red/green: classified READY by oreo-lot1 (red on main, green on head merged with main); head
74bd28ac71unchanged since 2026-11-26, before that run.Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
d48a957bbin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)