Skip to content

-1 index error in certain cases #317

@bernard-crnkovic

Description

@bernard-crnkovic

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions