From a900d40fed764df28da506748d6f7e837666f23b Mon Sep 17 00:00:00 2001 From: "Walter.Kolczynski" Date: Wed, 7 Dec 2022 15:26:13 -0600 Subject: [PATCH] Recursively convert dict to AttrDict when making an AttrDict 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. --- ush/python/pygw/src/pygw/attrdict.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ush/python/pygw/src/pygw/attrdict.py b/ush/python/pygw/src/pygw/attrdict.py index 1641969597..f2add20a19 100644 --- a/ush/python/pygw/src/pygw/attrdict.py +++ b/ush/python/pygw/src/pygw/attrdict.py @@ -44,6 +44,8 @@ def __setitem__(self, name, value): object.__getattribute__(self, '__frozen')) if isFrozen and name not in super(AttrDict, self).keys(): raise KeyError(name) + if isinstance(value, dict): + value = AttrDict(value) super(AttrDict, self).__setitem__(name, value) try: p = object.__getattribute__(self, '__parent')