question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update() is broken as of 3.4.3

See original GitHub issue

Given this sample code:

import box

if __name__ == '__main__':
    b = box.Box({
        'one': {
            'sub1': 'monkey',
            'sub2': 'goat',
        }
    }, box_it_up = True)

    print(f'box: {b}')
    print(f'one is a {type(b.one)}')
    print(f'expect monkey: {b.one.sub1}')
    print(f'expect goat: {b.one.sub2}')
            
    b.update({'one': {'sub2': 'alpaca'}})
    print(f'one is a {type(b.one)}')
    print(f'expect monkey: {b.one.sub1}')
    print(f'expect alpaca: {b.one.sub2}')

It works with < 3.4.3:

box: {'one': {'sub1': 'monkey', 'sub2': 'goat'}}
one is a <class 'box.Box'>
expect monkey: monkey
expect goat: goat
one is a <class 'box.Box'>
expect monkey: monkey
expect alpaca: alpaca

But using >= 3.4.3, this is the result:

box: {'one': {'sub1': 'monkey', 'sub2': 'goat'}}
one is a <class 'box.Box'>
expect monkey: monkey
expect goat: goat
one is a <class 'dict'>
Traceback (most recent call last):
  File "./test.py", line 16, in <module>
    print(f'expect monkey: {b.one.sub1}')
AttributeError: 'dict' object has no attribute 'sub1'

I notice there were changes to the update() method.

(edited: added some code to print out the types, which show the difference)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
alertedsnakecommented, Sep 28, 2019

Hooray:

box: {'one': {'sub1': 'monkey', 'sub2': 'goat'}}
one is a <class 'box.Box'>
expect monkey: monkey
expect goat: goat
one is a <class 'box.Box'>
expect monkey: monkey
expect goat: alpaca

Looks great! Thanks for the quick work on this, and for the excellent library!

1reaction
alertedsnakecommented, Sep 27, 2019

Thanks! It actually took me about an hour to dig in enough to find the cause - we subclass Box with a bunch of extra logic, so there were a lot of places it could have been.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolved - Plesk CentOS 7.8 ImageMagick Update Error
I ran the updates with yum clean all && yum -y update --skip-broken now its waiting for plesk to recompile the php-imagick rpm's...
Read more >
Compatibility with gulp-sass 4.1.1 broken with bootstrap-sass ...
1", will update to 3.4.3 and break every project. If the change is released under 3.5 or 4.0 , then it wouldn't be...
Read more >
Yum update fails due to dependency resolution
Hi, I am trying to update packages in RedHat 7.6 and I keep getting this error due to dependency resolution. I have tried...
Read more >
Link to Comments archive on bottom of page broken as of 3.4.3
I have tried with all plugins disabled. Still broken. It is definitely a bug in Atahualpa 3.4.3+ as it is still working if...
Read more >
[SOLVED] Frontend editing broken after migrating to 3.4.3 - Page 3 ...
Hello, After migrating Joomla from 2.5.8 to 3.4.3, frontend editing is broken; Save does not react, only loading start page in the... -...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found