[ python-Bugs-1263635 ] type() and isinstance() do not call __getattribute__
SourceForge.net
noreply at sourceforge.net
Mon Feb 20 23:10:05 CET 2006
Bugs item #1263635, was opened at 2005-08-19 02:07
Message generated for change (Comment added) made by gbrandl
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1263635&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Per Vognsen (pervognsen)
Assigned to: Nobody/Anonymous (nobody)
Summary: type() and isinstance() do not call __getattribute__
Initial Comment:
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.)
----------------------------------------------------------------------
>Comment By: Georg Brandl (gbrandl)
Date: 2006-02-20 22:10
Message:
Logged In: YES
user_id=849994
Closing as I feel Raymond's right.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2005-08-26 08:48
Message:
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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1263635&group_id=5470
More information about the Python-bugs-list
mailing list