Skip to content

Fix array-of-tables assignment serialization and list storage - #631

Open
kokotatan wants to merge 1 commit into
python-poetry:masterfrom
kokotatan:fix-aot-slice-assignment
Open

kokotatan wants to merge 1 commit into
python-poetry:masterfrom
kokotatan:fix-aot-slice-assignment

Conversation

@kokotatan

Copy link
Copy Markdown

Summary

Replacing or inserting a slice of an array of tables currently converts the entire replacement list to an ordinary Array, turning replacement dictionaries and Table objects into inline tables. Replacing the first table with doc["a"][:1] = [{"x": 3}] can therefore render x = 3[[a]] without a newline, producing invalid TOML.

Assignments also update only the AoT's _body, leaving its inherited list storage stale. List equality and JSON serialization consequently return old values; after a length-changing slice assignment, a later deletion can raise IndexError.

Convert each slice replacement independently using the AoT as its parent, then update both representations with the converted value. Integer assignment uses the same storage synchronization. Python's slice insertion, deletion, and extended-slice length checks remain intact.

The 12 regression cases cover dictionaries, existing tables, insertion, negative bounds, positive and negative extended slices, empty replacement, mismatched extended lengths without mutation, integer replacement, and deletion after insertion. They check TOML round trips, list equality, and JSON serialization. On unchanged upstream source, 10 fail and 2 pass; all 12 pass with the fix.

Validation on Python 3.10, 3.13, and 3.14 / Windows:

  • Full suite, including the initialized toml-test submodule: 1,080 passed on each version.
  • All pinned pre-commit hooks passed for both changed files.
  • Mypy reports the same 29 errors in four files reproduced on an unchanged upstream checkout (five existing source errors and 24 in the vendored tests/toml-test/gen.py); no new errors.

Agent Drafting Metadata

  • Agent: OpenAI Codex
  • Model: GPT-6
  • Notes: AI assistance was used to investigate the defect, implement the patch, write regression tests, and draft this PR. The patch received a separate review, and the regression failures and validation results above were executed locally. Submitted by kokotatan with authorization.

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