Repository navigation
Commit de68fd0
Fix ParseError when a sub-table extends an array of tables out of order (python-poetry#498)
* Fix ParseError when a sub-table extends the last array-of-tables element after an unrelated table
When a sub-table header such as [fruit.apple.texture] follows the array
[[fruit]] with an unrelated table in between, the parser rebuilds it as a
fresh super table named "fruit" and tries to append it to the document,
colliding with the existing array of tables and raising
ParseError: Key "fruit" already exists.
even though the document is valid TOML 1.0.0. The contiguous form (no
intervening table) already worked because the sub-table is consumed while
the array element is still being parsed.
A sub-table header that refers to an existing array of tables extends the
array's last element, regardless of any tables defined in between, so merge
its contents into that element instead of treating it as a redefinition.
Defining a non-super table with the same name as an array (e.g. [fruit]
after [[fruit]]) is still a genuine conflict and continues to raise.
Fixes python-poetry#261
* Document the out-of-order array-of-tables round-trip limitation
---------
Co-authored-by: Frost Ming <[email protected]>1 parent c46482b commit de68fd0
4 files changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
29 | 38 | | |
30 | 39 | | |
31 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
242 | 261 | | |
243 | 262 | | |
244 | 263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
263 | 273 | | |
264 | 274 | | |
265 | 275 | | |
| |||
0 commit comments