You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tomlkit API returns internal classes such as tomlkit.items.Bool to represent parsed values.
There is also a method unwrap() which converts the parse tree into a plain Python dictionary-and-list representation.
(At least this is my understanding of unwrap(); please correct me if I am wrong.)
However in certain cases, the return value from unwrap() still contains tomlkit internal objects.
I fully agree that the answer to my query type(doc["x"]["z"]["a"][0]) is tomlkit.items.Bool.
Since I am querying the tomlkit document structure, the query returns an internal tomlkit object to represent the boolean value.
However my last query type(doc.unwrap()["x"]["z"]["a"][0]) looks into the unwrapped data structure which should no longer contains tomlkit types. It should return an instance of bool, but I still get tomlkit.items.Bool.
This issue disappears if even a slight change is made to the TOML document.
It seems that the issue is related to the fact that unwrapping does not proceed past an instance of OutOfOrderTableProxy because it is not a subclass of tomlkit.items.Item.
This issue applies to the latest commit 6512eaa on master.
It doesn't seem to apply to the latest release v0.11.6.
I'm experimenting with a TOML fuzzer which revealed this issue. I guess most normal applications are not likely to hit this case, so I understand if this gets low priority. It still seems worthwhile to fix it though.
Edit: The first version of this issue report was accidentally a copy of another issue. Sorry, I pressed Enter at the wrong moment. Now fixed.
The text was updated successfully, but these errors were encountered:
ghost
changed the title
unwrap() sometimes returns
unwrap() sometimes returns an internal tomlkit object
Jan 24, 2023
The tomlkit API returns internal classes such as
tomlkit.items.Bool
to represent parsed values.There is also a method
unwrap()
which converts the parse tree into a plain Python dictionary-and-list representation.(At least this is my understanding of
unwrap()
; please correct me if I am wrong.)However in certain cases, the return value from
unwrap()
still contains tomlkit internal objects.For example:
I fully agree that the answer to my query
type(doc["x"]["z"]["a"][0])
istomlkit.items.Bool
.Since I am querying the tomlkit document structure, the query returns an internal tomlkit object to represent the boolean value.
However my last query
type(doc.unwrap()["x"]["z"]["a"][0])
looks into the unwrapped data structure which should no longer contains tomlkit types. It should return an instance ofbool
, but I still gettomlkit.items.Bool
.This issue disappears if even a slight change is made to the TOML document.
It seems that the issue is related to the fact that unwrapping does not proceed past an instance of
OutOfOrderTableProxy
because it is not a subclass oftomlkit.items.Item
.This issue applies to the latest commit 6512eaa on master.
It doesn't seem to apply to the latest release v0.11.6.
I'm experimenting with a TOML fuzzer which revealed this issue. I guess most normal applications are not likely to hit this case, so I understand if this gets low priority. It still seems worthwhile to fix it though.
Edit: The first version of this issue report was accidentally a copy of another issue. Sorry, I pressed Enter at the wrong moment. Now fixed.
The text was updated successfully, but these errors were encountered: