Fix DotDict for legacy python 2 support.
@@ -1806,10 +1806,13 @@ class DotDict(collections.OrderedDict):
# => AttributeError
"""
+ # forward certain attributes to the super class in python 2
+ FORWARD_SUPER = ("_OrderedDict__root", "_OrderedDict__map")
+
def __getattr__(self, attr):
- if attr == "_OrderedDict__root":
+ if six.PY2 and attr in self.FORWARD_SUPER:
return super(DotDict, self).__getattr__(attr)
- else:
+
try:
return self[attr]
except KeyError:
@@ -1817,6 +1820,9 @@ class DotDict(collections.OrderedDict):
self.__class__.__name__, attr))
def __setattr__(self, attr, value):
+ if six.PY2 and attr in self.FORWARD_SUPER:
+ return super(DotDict, self).__setattr__(attr, value)
+
self[attr] = value
def copy(self):
