Skip to content

Convert containers assigned to BoxList items and slices - #329

Closed
Eric3-jp wants to merge 1 commit into
cdgriffith:developfrom
Eric3-jp:fix-boxlist-assignment-conversion
Closed

Eric3-jp wants to merge 1 commit into
cdgriffith:developfrom
Eric3-jp:fix-boxlist-assignment-conversion

Conversation

@Eric3-jp

Copy link
Copy Markdown

Replacing a BoxList element with a dictionary currently stores a plain dict, so attribute access stops working:

from box import BoxList

rows = BoxList([{"name": "before"}])
rows[0] = {"name": "after"}
rows[0].name  # AttributeError before this change; "after" afterward

Route ordinary item assignment, dotted list-index assignment, and slice assignment through the existing _convert() helper. This gives replacements the same recursive conversion and option propagation as append() and insert(). Slice assignments still accept iterators, and box_intact_types remains honored.

The regression tests cover positive/negative indices, dotted indices with default-list extension, dictionaries, nested lists, and both ordinary and extended slices. Compatibility tests cover intact types, invalid extended-slice lengths, and frozen lists. Includes the changelog and contributor updates requested by CONTRIBUTING.rst.

Validation on Ubuntu 24.04 (WSL), CPython 3.12.3:

  • Before the implementation change: 10 failed, 3 passed in the new test selection.
  • Full pure-Python suite: 172 passed.
  • Cython 3.3.0 build via python setup.py build_ext --inplace: passed; full suite with the compiled box_list extension loaded: 172 passed.
  • Black 24.10.0 with .black.toml: passed for both changed Python files.
  • mypy 1.13.0: no issues in 8 source files.
  • git diff --check: passed.

This change and its tests were prepared and validated with OpenAI Codex assistance.

@Eric3-jp Eric3-jp closed this by deleting the head repository Sep 23, 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.

1 participant