Repository navigation
Conversation
The copy dropped the table-key bookkeeping that __setstate__ preserves on pickle, so the merge heuristic in _handle_merge crashed with IndexError when appending a table whose name already existed in the copy.
Contributor
|
Explain why not #672 |
Contributor
Author
|
Good catch — I missed #672: my duplicate search keyed on the IndexError symptom wording and didn't surface its title. It was opened 8 days earlier and the source fix is identical (carry |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Container.__copy__copies the dict mirror,_body,_mapand_out_of_order_keys, but not_table_keys— while__setstate__does restore that field when pickling, and_raw_appendmaintains it for every keyed table. With the bookkeeping missing, the merge heuristic in_handle_mergereadsself._table_keys[-1]and crashes on an empty list, so a copied container cannot append a table whose name already exists, while the same append on the original works:The public
doc.copy()path hits the same crash viadoc_copy.append("a", super_table). Fix is one line in__copy__(c._table_keys += self._table_keysextends the new container's fresh list, so the original is unaffected).New test
test_toml_document_copy_keeps_table_keysappends a super table to a copy and asserts the merged rendering round-trips with both tables intact; it raisesIndexErroron current master. Full suite:pytest tests/ --ignore=tests/test_toml_tests.py— 524 passed (523 baseline + the new test).Agent Drafting Metadata