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

BoxKeyError when constructing a Box with box_dots = True in v7.0.0 #250

Open
roosephu opened this issue Feb 12, 2023 · 2 comments
Open

BoxKeyError when constructing a Box with box_dots = True in v7.0.0 #250

roosephu opened this issue Feb 12, 2023 · 2 comments

Comments

@roosephu
Copy link

To reproduce:

>>> import box
>>> box.__version__
'7.0.0'
>>> box.Box({'a.b': 1})
Box({'a.b': 1})
>>> box.Box({'a.b': 1}, box_dots=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "box/box.py", line 286, in box.box.Box.__init__
  File "box/box.py", line 653, in box.box.Box.__setitem__
box.exceptions.BoxKeyError: "'<class 'box.box.Box'>' object has no attribute a"

It seems to work in v6.0.2:

>>> import box
>>> box.__version__
'6.0.2'
>>> box.Box({'a.b': 1})
Box({'a.b': 1})
>>> box.Box({'a.b': 1}, box_dots=True)
Box({'a.b': 1})

Python 3.10.9.

@roosephu
Copy link
Author

This might be related to #170.

>>> import box
>>> box.__version__
'7.0.0'
>>> box.Box({'a.b': 1}, default_box=True)
Box({'a.b': 1})
>>> box.Box({'a.b': 1}, default_box=True, box_dots=True)
Box({'a': {'b': 1}})

That is, we have to set default_box=True to avoid BoxKeyError.

@roosephu
Copy link
Author

Found this is in the list of breaking changes which unfortunately I didn't read through. The examples in the wiki should be updated, though.

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

No branches or pull requests

2 participants