Emptying a nested array of tables before an out-of-order super-table renders invalid TOML (0.15.2, since #567)
Les mainteneurs répondent en général sous 2 jours
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 45/100
Piste de recherche
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}}.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 864
- Forks
- 207
- Merge moyen
- 3 j 22 h
- PR mergées (30 j)
- 25
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python-poetry/tomlkit
-
`update()` on an out-of-order table raises `IndexError` after a sub-table fragment was poppedPeut-être pris @rajmodi8905 l’a pris il y a 14 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
python-poetry/tomlkit#675 · 3 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
AttributeError on an out-of-order table under an indented header (4+ levels)Peut-être pris @cig13zs l’a pris il y a 20 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 18/100
python-poetry/tomlkit#661 ·
Les mainteneurs répondent en général sous 2 jours
-
In-place array repetition changes values without updating serialized TOMLPeut-être pris @harbinresearcher l’a pris il y a 23 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 35/100
python-poetry/tomlkit#646 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
tomlkit 0.15.1 fails on out-of-order table headerPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
python-poetry/tomlkit#632 ·
Les mainteneurs répondent en général sous 2 jours
-
`dumps(sort_keys=True)` only sorts the top level of a parsed document (nested tables / inline tables / AoT keep original order)Peut-être pris @Sreekant13 l’a pris il y a 37 jours. Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
python-poetry/tomlkit#614 · 2 commentaires ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de python-poetry/tomlkit
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
area:docs documentation effort:M ready-for-agent
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
mczielinski/ob-analytics#423 ·
Les mainteneurs répondent en général sous 1 jour
-
infra
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 3 jours
-
documentation
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
vllm-project/vllm-ascend#21033 ·
Les mainteneurs répondent en général sous 1 jour