Skip to content

Commit cab4faf

Browse files
Recursively convert dict to AttrDict when making an AttrDict (#1154)
Dicts within an AttrDict were not being converted to AttrDicts at creation/update time. This meant (among other things) when updating, nested dicts of the same name would be overwritten instead of merged.
1 parent 21056c1 commit cab4faf

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ush/python/pygw/src/pygw/attrdict.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def __setitem__(self, name, value):
4444
object.__getattribute__(self, '__frozen'))
4545
if isFrozen and name not in super(AttrDict, self).keys():
4646
raise KeyError(name)
47+
if isinstance(value, dict):
48+
value = AttrDict(value)
4749
super(AttrDict, self).__setitem__(name, value)
4850
try:
4951
p = object.__getattribute__(self, '__parent')

0 commit comments

Comments
 (0)