python-poetry/tomlkit

-1 index error in certain cases

macabrus opened this issue · 1 comments

https://github.com/sdispater/tomlkit/blob/cfc99766fc9fc4f05c57c45487bea319e96e1eba/tomlkit/container.py#L216C39-L216C39

This line throws index error in certain cases.

import tomlkit

doc = tomlkit.parse('''
[a]
[a.b]
b = 0
''')

for label, obj in doc['a'].items():
    obj[tomlkit.key(['a', 'b'])] = 1
    obj[tomlkit.key(['a', 'c'])] = 2
self._table_keys[-1] != current_body_element[0]
    ~~~~~~~~~~~~~~~~^^^^
IndexError: list index out of range

am i misusing an API or is the implementation wrong? issue also occurs when using .add() method instead of setitem()

It doesn't throw any error with the latest master branch.