This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: type() and isinstance() do not call __getattribute__
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, pervognsen, rhettinger
Priority: normal Keywords:

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) * (Python committer) 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) * (Python committer) 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:12adminsetgithub: 42290
2005-08-19 02:07:29pervognsencreate