Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`update()` on an out-of-order table raises `IndexError` after a sub-table fragment was popped

オープン
#675 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@rajmodi8905 がすでに取り組んでいます。

2026年10月22日 から。

  • #677 @rajmodi8905 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

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 ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python-poetry/tomlkit のほかの issue

python-poetry/tomlkit の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。