Emptying a nested array of tables before an out-of-order super-table renders invalid TOML (0.15.2, since #567)
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
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}}.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 864
- Fork
- 207
- Merge medio
- 3g 22h
- PR unite (30g)
- 25
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python-poetry/tomlkit
-
`update()` on an out-of-order table raises `IndexError` after a sub-table fragment was poppedForse già presa @rajmodi8905 l’ha presa 12 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
python-poetry/tomlkit#675 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
AttributeError on an out-of-order table under an indented header (4+ levels)Forse già presa @cig13zs l’ha presa 19 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 18/100
python-poetry/tomlkit#661 ·
I maintainer di solito rispondono entro 2 giorni
-
In-place array repetition changes values without updating serialized TOMLForse già presa @harbinresearcher l’ha presa 22 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
python-poetry/tomlkit#646 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
tomlkit 0.15.1 fails on out-of-order table headerForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
python-poetry/tomlkit#632 ·
I maintainer di solito rispondono entro 2 giorni
-
`dumps(sort_keys=True)` only sorts the top level of a parsed document (nested tables / inline tables / AoT keep original order)Forse già presa @Sreekant13 l’ha presa 35 giorni fa. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
python-poetry/tomlkit#614 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di python-poetry/tomlkit
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
521xueweihan/HelloGitHub#4237 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
jejjohnson/gaussx#721 ·
I maintainer di solito rispondono entro 1 giorno
-
mock-core-configs/etc/mock/rocky-10-riscv64.cfg contains the wrong architecture in config_opts['root']Forse già presa @jasonmontleon l’ha presa 4 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 94/100
rpm-software-management/mock#1834 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
elastic/elastic-otel-python#683 ·
I maintainer di solito rispondono entro 1 giorno
-
ci-rerun: collect.py fails a whole pr-babysit cycle on one transient GitHub 5xx and never retriesApertafollow-up
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno