Skip to content

Fix AttributeError on an out-of-order table under an indented header - #663

Merged
frostming merged 3 commits into
python-poetry:masterfrom
cig13zs:fix-nested-oot-trivia
Nov 5, 2026
Merged

frostming merged 3 commits into
python-poetry:masterfrom
cig13zs:fix-nested-oot-trivia

Conversation

@cig13zs

@cig13zs cig13zs commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #661. Table.append copies the parent's indent onto the item it just stored, but when that key is split out of order the lookup returns an OutOfOrderTableProxy, which has no trivia. The fix skips the proxy, since its parts already keep their own indentation. #263 was the same crash one level up and only stopped happening because the outermost super table has no indent.

Parsing " [a.b.c.d]\n[a.b.c]" raised "'OutOfOrderTableProxy' object has
no attribute 'trivia'". The intermediate tables created for an indented
header carry its indent, and Table.append copies that indent onto the
item it just stored. When that key is now split out of order, the lookup
returns an OutOfOrderTableProxy, which has no trivia.

Skip the indent copy for the proxy; its parts keep their own
indentation. Issue python-poetry#263 was the three-level form of this, which only
stopped failing because the outermost super table has no indent.

@Wkhanex Wkhanex left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted validation at d0484992a8bd on Python 3.12.14: I expanded the indentation case to spaces, a tab, and mixed space/tab indentation at depths 4–6, for both a table and an array of tables. Each input also had an intervening unrelated table and a value added through the reopened parent. All 18 combinations parsed and preserved the original text before mutation, and their serialized data after mutation matched tomllib. The 23 focused out-of-order tests passed.

The mutation check matters here because skipping proxy trivia must leave its component tables usable after the initial parse, as well as avoid the AttributeError. I did not find a discrepancy in those cases.

@cig13zs

cig13zs commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Friendly ping @frostming: this still merges cleanly on current master (no conflicts after 0.15.2) and CI is green. Happy to rebase or adjust anything if you'd prefer a different approach.

@cig13zs

cig13zs commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

hey @frostming, bumping this one since #664 went in. same area of the code, still merges clean on master. happy to rebase or change the approach if you'd rather fix it another way

@human-attestation

Copy link
Copy Markdown

✅ Human Attestation: @frostming attested this PR at commit 737037e (2026-11-05T07:58:48.422Z).

I have read and understood all agent-written code in this PR. / 我已阅读并理解此 PR 中 Agent 编写的全部代码。

Later pushes to this PR stay attested. Attestation page

@frostming
frostming merged commit 398c53e into python-poetry:master Nov 5, 2026
26 checks passed
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.

AttributeError on an out-of-order table under an indented header (4+ levels)

3 participants