Open Chaz6 opened 1 year ago
I'm curious to see what exactly changed in 3.11, because after delving deeper into the interpreter and such, I see a lot of "changed in 3.11".
I don't think it was 3.11, but the changes introduced in commit 9893e1a.
Commits prior to that one work as expected running 3.11.
9893e1a fails with a recursion error and the current commit (eed0e84) fails with the attribute error above.
Technically the current commit works up to the depth of c
(a.b.c = 1
), but fails at anything deeper than that like a.b.c.d = 1
.
It appears the not self._temp
condition in the if statement of DotDict.__getattr__
is the culprit:
def __getattr__(self, __name: str) -> Any: if __name not in self.__dict__ and not self._temp: self.__dict__[__name] = DotDict(temp=True, key=__name, parent=self) else: del self._parent.__dict__[self._key] raise AttributeError("No attribute '%s'" % __name) return self.__dict__[__name]
When doing a.b.c.d = 1
, b
gets added to a
, but with temp=True
.
So then when it comes to c
, since self._temp
is True
for b
, the else statement executes and the error is raised.