Since __getattr__ can be called on uninitialized instances (i.e. with no
attributes), it can enter an infinite recursion while trying to access
some instance attributes.
Fix that by ignoring requests for dunder names (__XXX__), since they are
resolved without __getattr__ when needed by a builtin, and are mostly
supposed to be class attributes in other cases. That means __getattr__
is not supposed to receive requests to such names often, and these will
(almost) surely not be anything the API can offer since usage of such
names is reserved for future expansion of the language.
Since
__getattr__
can be called on uninitialized instances (i.e. with no attributes), it can enter an infinite recursion while trying to access some instance attributes.Fix that by ignoring requests for dunder names (
__XXX__
), since they are resolved without__getattr__
when needed by a builtin, and are mostly supposed to be class attributes in other cases. That means__getattr__
is not supposed to receive requests to such names often, and these will (almost) surely not be anything the API can offer since usage of such names is reserved for future expansion of the language.