cdgriffith / Box

Python dictionaries with advanced dot notation access
https://github.com/cdgriffith/Box/wiki
MIT License
2.61k stars 106 forks source link

`default_box=True` prevents accessing `box_safe_prefix`ed items #141

Closed Pymancer closed 4 years ago

Pymancer commented 4 years ago
>>> from box import Box
>>> b1 = Box({'a': {'from': {'b':1}}})
>>> b1.a.xfrom
<Box: {'b': 1}>
>>> b3 = Box({'a': {'from': {'b':1}}}, default_box=True)
>>> b3.a.xfrom
<Box: {}>
>>> import box
>>> box.__version__
'4.2.1'
cdgriffith commented 4 years ago

Without looking at code my guess is this is because it does a quick litterally lookup for that key and doesn't find it, so automatically gives back the new default box.

I am not sure if this behavior should happen at all for already safe attributes like exampled though, will need to look into that as well. Totally forgot from was a reserved keyword when I typed this reply.

cdgriffith commented 4 years ago

Addressing in 4.2.2 https://github.com/cdgriffith/Box/pull/142

cdgriffith commented 4 years ago

Fixed in 4.2.2