Skip to content

Preserve BoxList comments with index protocol objects - #355

Merged
cdgriffith merged 1 commit into
cdgriffith:developfrom
parijat1222q:fix-boxlist-index-comments
Nov 11, 2026
Merged

cdgriffith merged 1 commit into
cdgriffith:developfrom
parijat1222q:fix-boxlist-index-comments

Conversation

@parijat1222q

Copy link
Copy Markdown
Contributor

Fixes #354.

Normalize index-protocol objects once before BoxList.insert, pop and item deletion mutate the list. Reuse the resulting integer for comment bookkeeping, so valid __index__ objects do not raise after a successful mutation and leave comments attached to the wrong items. Item deletion still delegates invalid non-index keys to list to preserve its existing error behavior. Slice and dotted-key paths stay unchanged.

Five added source lines, including the import. Added 38 regression/control cases for all three operations, positive/negative/clamped/out-of-bounds indexes, with and without comments, invalid index conversion, and a stateful index that must be evaluated only once. Against unchanged develop fa7ca67d16c5619f1f3f2c542284100abd3c1383, 14 cases fail and 24 controls pass. All 38 pass with the fix.

Validation on Linux:

  • Full pure-Python suite on CPython 3.11, 3.12 and 3.15: 733 passed, 1 skipped each.
  • Built the Cython wheel on CPython 3.15, installed it in a separate environment, verified box_list loads from the compiled .so, then ran an isolated copy of the full tests: 733 passed, 1 skipped.
  • The skip is intentional: the ruamel round-trip dumper never sorts.
  • Whole-package statement and branch coverage: 100%, 1,851 statements and 936 branches, with the required coverage gate passing.
  • Full repository Ruff check and format check: passed.
  • Mypy on all box modules: passed.
  • Compiled sdist/wheel build and Twine checks: passed.
  • git diff --check: passed.

Updated CHANGES.rst and AUTHORS.rst as the contribution guide requests; targets develop, not master. No dependency, API or performance claim, release, or unrelated comment behavior change. Other platforms, PyPy, and the complete remote packaging matrix were not run locally.

Found through source inspection and local reproduction, not a claimed production incident.

@cdgriffith
cdgriffith merged commit 0c93d9f into cdgriffith:develop Nov 11, 2026
@cdgriffith cdgriffith mentioned this pull request Nov 13, 2026
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