Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type() and isinstance() do not call __getattribute__ #42290

Closed
pervognsen mannequin opened this issue Aug 19, 2005 · 3 comments
Closed

type() and isinstance() do not call __getattribute__ #42290

pervognsen mannequin opened this issue Aug 19, 2005 · 3 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@pervognsen
Copy link
Mannequin

pervognsen mannequin commented Aug 19, 2005

BPO 1263635
Nosy @birkenfeld, @rhettinger

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2006-02-20.22:10:05.000>
created_at = <Date 2005-08-19.02:07:29.000>
labels = ['interpreter-core']
title = 'type() and isinstance() do not call __getattribute__'
updated_at = <Date 2006-02-20.22:10:05.000>
user = 'https://bugs.python.org/pervognsen'

bugs.python.org fields:

activity = <Date 2006-02-20.22:10:05.000>
actor = 'georg.brandl'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Interpreter Core']
creation = <Date 2005-08-19.02:07:29.000>
creator = 'pervognsen'
dependencies = []
files = []
hgrepos = []
issue_num = 1263635
keywords = []
message_count = 3.0
messages = ['26080', '26081', '26082']
nosy_count = 3.0
nosy_names = ['georg.brandl', 'rhettinger', 'pervognsen']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1263635'
versions = ['Python 2.4']

@pervognsen
Copy link
Mannequin Author

pervognsen mannequin commented Aug 19, 2005

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.)

@pervognsen pervognsen mannequin closed this as completed Aug 19, 2005
@pervognsen pervognsen mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Aug 19, 2005
@rhettinger
Copy link
Contributor

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.

@birkenfeld
Copy link
Member

Logged In: YES
user_id=849994

Closing as I feel Raymond's right.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

2 participants