Open brynpickering opened 9 months ago
Confirmed with that file the behavior, with both ruamel.yaml and pyyaml as backends, so is from something in my code side looping. Thanks for raising the issue will look into!
Anything new on this one? I have a similar problem but with some JSON:
Box.from_yaml(resp.text, box_dots=True)
Traceback (most recent call last):
File ".../pydevd_asyncio_utils.py", line 117, in _exec_async_code
result = func()
File "<input>", line 1, in <module>
File "box/box.py", line 1050, in box.box.Box.from_yaml
File "box/box.py", line 291, in box.box.Box.__init__
File "box/box.py", line 671, in box.box.Box.__setitem__
File "box/box.py", line 574, in box.box.Box.__convert_and_store
File "box/box.py", line 291, in box.box.Box.__init__
File "box/box.py", line 671, in box.box.Box.__setitem__
File "box/box.py", line 583, in box.box.Box.__convert_and_store
File "box/box_list.py", line 52, in box.box_list.BoxList.__init__
File "box/box_list.py", line 110, in box.box_list.BoxList.append
File "box/box_list.py", line 100, in box.box_list.BoxList._convert
File "box/box.py", line 291, in box.box.Box.__init__
File "box/box.py", line 671, in box.box.Box.__setitem__
File "box/box.py", line 574, in box.box.Box.__convert_and_store
File "box/box.py", line 291, in box.box.Box.__init__
File "box/box.py", line 671, in box.box.Box.__setitem__
File "box/box.py", line 574, in box.box.Box.__convert_and_store
File "box/box.py", line 291, in box.box.Box.__init__
File "box/box.py", line 664, in box.box.Box.__setitem__
box.exceptions.BoxKeyError: "'<class 'box.box.Box'>' object has no attribute tenant"
I am pretty sure Box
chokes on /
or .
in the... keys maybe?
...
metadata:
labels:
kubed.appscode.com/origin.cluster: unicorn
...
Traceback (most recent call last):
File "/home/schroederp/.local/share/JetBrains/IntelliJIdea2024.1/python/helpers/pydev/pydevconsole.py", line 364, in runcode
coro = func()
File "<input>", line 1, in <module>
File "box/box.py", line 303, in box.box.Box.__init__
File "box/box.py", line 671, in box.box.Box.__setitem__
File "box/box.py", line 574, in box.box.Box.__convert_and_store
File "box/box.py", line 291, in box.box.Box.__init__
File "box/box.py", line 671, in box.box.Box.__setitem__
File "box/box.py", line 574, in box.box.Box.__convert_and_store
File "box/box.py", line 291, in box.box.Box.__init__
File "box/box.py", line 664, in box.box.Box.__setitem__
box.exceptions.BoxKeyError: "'<class 'box.box.Box'>' object has no attribute kubed"
@paulschroeder-tomtom good find, yes.
If there are keys with .
or []
in them, box dots will treat them as if they should break them apart.
For example in @brynpickering YAML has keys like '^[^_^\d][\w]*$': {}
that it will fail on.
I don't see any what Box could really support those cases, but should at least have a check on box creation if something is going to break it like that and give a clear error.
Ok, I sad but then it is like that. WIll you create an improve on the error message?
I have a YAML schema (see here) which I want to be able to get the flattened dict keys for - something that
Box
is well placed to provide with its dot notation.However, I get a segfault when loading the YAML file with:
It loads successfully with:
But then I lose the ability to inspect the flattened keys (
schema.keys(dotted=True)
).