Issue 1263635: type() and isinstance() do not call getattribute (original) (raw)
Issue1263635
Created on 2005-08-19 02:07 by pervognsen, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg26080 - (view) | Author: Per Vognsen (pervognsen) | Date: 2005-08-19 02:07 |
The built-in functions type() and isinstance() do not call __getattribute__ for instances of user-defined classes. Thus, for instance, x.__class__ == sometype and type(x) == sometype can give inconsistent results. I ran into this problem in writing a transparent persistence system, where instances of proxy classes are used as stand-ins for unloaded objects and the proxy does just-in-time loading by overloading __getattribute__ and __setattr__ (which changes __class__). (This applies to 2.4.1.) | ||
msg26081 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2005-08-26 08:48 |
Logged In: YES user_id=80475 I don't think this is going to change. A number of builtins directly access an object's structure and do not respect overrides via __getattribute__. This is somewhat intrinsic the Python's current design. | ||
msg26082 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2006-02-20 22:10 |
Logged In: YES user_id=849994 Closing as I feel Raymond's right. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:12 | admin | set | github: 42290 |
2005-08-19 02:07:29 | pervognsen | create |