Why would you expect it to end up in a loop?
instance.__dict__[attr] = value
is basically what object.__setattr__(instance,attr,value)
does (for normal attributes). Note that __dict__[attr] = whatever
does not call __setattr__
at all. It calls __setitem__
which is a different method entirely.