`update()` on an out-of-order table raises `IndexError` after a sub-table fragment was popped
メンテナーはふだん 2 日以内に返信
評価
調査の方向性
Start with the reproduced tomlkit call in the issue and inspect tomlkit/container.py around __setitem__ line 1262, where the traceback indexes _tables. Compare the failing update() call with setting the same keys individually after pop. Done means the update no longer raises IndexError and the document can be dumped as expected.
索引モデルが issue の本文から書いたものです。
説明
Versions tested: tomlkit 0.15.2 from PyPI (the newest release on 2026-10-21) and the master branch at
eddd27e43a62fe58707c311bfad2f52e72493f53 (its head on 2026-10-21); Python 3.11.10 on Linux.
Reproduce (one command):
python3 -c '
import tomlkit
doc = tomlkit.parse("[y.y.b]\nc = 1\n[y]\nd = 1\n[y.b]\ne = 2\n[y.y]\n")
doc["y"]["y"].pop("b")
doc["y"].update({"y": [{"z": 1}], "b": {"e": -0.5}})
print(tomlkit.dumps(doc))
'
The document is valid TOML: tomllib.loads reads it as {'y': {'y': {'b': {'c': 1}}, 'd': 1, 'b': {'e': 2}}}.
Expected: the update succeeds and the document can be dumped.
Observed (the same on both versions):
File ".../tomlkit/container.py", line 1262, in __setitem__
old_value = self._tables[map_indices[0]][key]
~~~~~~~~~~~~^^^^^^^^^^^^^^^^
IndexError: list index out of range
Setting the two keys one at a time (doc["y"]["y"] = [{"z": 1}], then doc["y"]["b"] = {"e": -0.5}) after the same pop does not
raise. We have not looked for the cause.
Found while testing tomlkit's editing API against the standard library's tomllib with generated documents.
Possibly related: #196 (out-of-order sections), though that report is about _insert_after, not update().
- 主要言語
- Python
- スター
- 861
- フォーク
- 201
- 平均マージ
- 3日 22時間
- マージ済み PR(30日)
- 32
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-poetry/tomlkit のほかの issue
-
Speed up array appends対応中かも @harshitgupta31415 が 12 日前に担当しました。 オープン
難易度 4/5 1〜2日 初心者へのやさしさ 42/100
python-poetry/tomlkit#665 ·
メンテナーはふだん 2 日以内に返信
-
Deleting the last key under a dotted key in an inline table produces invalid TOML対応中かも @cig13zs が 12 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
python-poetry/tomlkit#662 ·
メンテナーはふだん 2 日以内に返信
-
AttributeError on an out-of-order table under an indented header (4+ levels)対応中かも @cig13zs が 12 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 18/100
python-poetry/tomlkit#661 ·
メンテナーはふだん 2 日以内に返信
-
In-place array repetition changes values without updating serialized TOML対応中かも @harbinresearcher が 15 日前に担当しました。 オープン
難易度 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 日以内に返信
python-poetry/tomlkit の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
btclib-org/btclib-wallet#587 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Judgment-Pack/judgment-pack-spec#275 ·
メンテナーはふだん 1 日以内に返信
-
ai-generated
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
documentation good first issue priority: low size: XS
難易度 1/5 1〜3時間 初心者へのやさしさ 92/100
yeongseon/azure-functions-doctor-python#651 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
Changaco/python-libarchive-c#146 ·