Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical data loss #113

Closed
ofek opened this issue Oct 25, 2020 · 5 comments · Fixed by #122
Closed

Critical data loss #113

ofek opened this issue Oct 25, 2020 · 5 comments · Fixed by #122

Comments

@ofek
Copy link

ofek commented Oct 25, 2020

Using latest 0.7.0:

>>> import tomlkit
>>>
>>> doc = tomlkit.parse("""
... [tool.poetry.foo]
... option = 'test'
...
... [tool.poetry.bar]
... option = 'test'
... """)
>>>
>>> doc
{'tool': {'poetry': {'foo': {'option': 'test'}, 'bar': {'option': 'test'}}}}
>>> doc['tool']
{'poetry': {'bar': {'option': 'test'}}}
>>> dict(doc['tool'])
{'poetry': {'bar': {'option': 'test'}}}

cc @frostming @sdispater

@eksortso
Copy link

Can you show us what print(doc) displays? Because there is a bug, but it doesn't cause critical data loss.

I tried your code using tomlkit 0.7.0 on Python 3.8.3. Here's what I got.

>>> print(doc)
{'tool': {'poetry': {'foo': {'option': 'test'}, 'bar': {'option': 'test'}}}}

>>> doc['tool']
{'poetry': {'bar': {'option': 'test'}}}


>>> doc['tool']['poetry']['foo']
{'option': 'test'}


>>> doc['tool']['poetry']['bar']
{'option': 'test'}

@ofek
Copy link
Author

ofek commented Oct 25, 2020

It shows the same as yours.

It is critical because I need to make copies of a subset of the document and referenced subsets don't contain everything.

@frostming
Copy link
Contributor

tomlkit's containers and tables inherits from built-in dict and has some but not all customized implementations of the magic methods. It often leads to issue where the native version of the method is called instead of the customized one.

@ofek
Copy link
Author

ofek commented May 7, 2021

Any update?

@frostming
Copy link
Contributor

I've created a fork of tomlkit v0.7.0 with the issue fixed, try it:

GitHub: https://github.com/frostming/atoml
PyPI: https://pypi.org/project/atoml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants