Emptying a nested array of tables before an out-of-order super-table renders invalid TOML (0.15.2, since #567)
メンテナーはふだん 2 日以内に返信
評価
調査の方向性
Start by running the reproduction in the issue: parse the [[a.b.c]] document, pop the element, and inspect the tomlkit.dumps output. The bug is in how an emptied array of tables is rendered when its super-table comes later in the document, which #567 changed; the issue says the parent commit of #567 produces valid output. Done when the output parses with both tomlkit.parse and tomllib.loads to {'a': {'b': {'c': []}, 'y': 1}}.
索引モデルが issue の本文から書いたものです。
説明
Versions tested: tomlkit 0.15.2 (tag a0b15eb), and master at d7def7d (2026-10-29); Python 3.12.
Reproduce:
import tomlkit
doc = tomlkit.parse("[[a.b.c]]\nx = 1\n\n[a]\ny = 1\n")
doc["a"]["b"]["c"].pop()
out = tomlkit.dumps(doc)
print(repr(out))
tomlkit.parse(out)
The input is valid TOML, and tomlkit parses it to {'a': {'b': {'c': [{'x': 1}]}, 'y': 1}}. After the pop, doc.unwrap() is {'a': {'b': {'c': []}, 'y': 1}}, as expected.
Observed: dumps returns 'a.b.c = []\n[a]\ny = 1\n', which declares a twice:
tomlkit.exceptions.ParseError: Redefinition of an existing table at line 3 col 0
tomllib.loads rejects it too: Cannot declare ('a',) twice (at line 2, column 3).
Expected: output that parses back to {'a': {'b': {'c': []}, 'y': 1}}, for example what tomlkit.dumps(doc.unwrap()) returns:
[a]
y = 1
[a.b]
c = []
Where it comes from: #567 renders an emptied array of tables as key = []. When the array sits under a super-table that is defined later in the document, the dotted key is emitted where the [[a.b.c]] header was, before [a]. On the parent commit of #567, the same steps produce output that parses. The same happens when [a] extends a.b with a dotted key, for example [[a.b.c]]\nx = 1\n[a]\nb.z = 1\n.
Related: #553, which #567 addressed in part, and #675, another failure after removing an element from an out-of-order table.
This came up while running generated tests on pairs of tomlkit pull requests that were open at the same time (#565 and #567). The reproduction above gives the same output on 0.15.2 and on master.
- 主要言語
- Python
- スター
- 864
- フォーク
- 207
- 平均マージ
- 3日 22時間
- マージ済み PR(30日)
- 25
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-poetry/tomlkit のほかの issue
-
`update()` on an out-of-order table raises `IndexError` after a sub-table fragment was popped対応中かも @rajmodi8905 が 12 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
python-poetry/tomlkit#675 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
-
AttributeError on an out-of-order table under an indented header (4+ levels)対応中かも @cig13zs が 18 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 18/100
python-poetry/tomlkit#661 ·
メンテナーはふだん 2 日以内に返信
-
In-place array repetition changes values without updating serialized TOML対応中かも @harbinresearcher が 22 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
python-poetry/tomlkit#646 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
tomlkit 0.15.1 fails on out-of-order table header再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
python-poetry/tomlkit#632 ·
メンテナーはふだん 2 日以内に返信
-
`dumps(sort_keys=True)` only sorts the top level of a parsed document (nested tables / inline tables / AoT keep original order)対応中かも @Sreekant13 が 35 日前に担当しました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
python-poetry/tomlkit#614 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
python-poetry/tomlkit の issue をすべて見る
似ている issue
-
ci-rerun: collect.py fails a whole pr-babysit cycle on one transient GitHub 5xx and never retriesオープンfollow-up
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
Built-in QUBO fallback applies bitwise xor to floating binary states対応中かも @iloveeyjafjalla が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
qboson/kaiwu-pytorch-plugin#1702 ·
メンテナーはふだん 3 日以内に返信
-
bug v2
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
modelcontextprotocol/python-sdk#3811 ·
メンテナーはふだん 1 日以内に返信
-
cost:cheap practicality:seen-in-the-wild severity:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
fairagro/m4.2_advanced_middleware_api#620 ·
メンテナーはふだん 1 日以内に返信