Amaury Forgeot d'Arc added the comment:
BTW**2: I've noticed that abc.py's __instancecheck__ gets called a lot
at times when I don't expect it. Can you research this a bit?
In classobject.c, method_call() calls PyObject_IsInstance() on the first
arg when the method is unbound.
This happens a
Amaury Forgeot d'Arc added the comment:
Corrected by revision 58958.
with is innocent. The problem is this function in abc.py which uses a
generator expression:
def __instancecheck__(cls, instance):
Override for isinstance(instance, cls).
return any(cls.__subclasscheck__(c)
Amaury Forgeot d'Arc added the comment:
__instancecheck__ should be simpler: all classes are new-style, how is
it possible to have different results for
instance.__class__
and
type(instance)
?
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1265
Christian Heimes added the comment:
Good work Amaury! :)
I also wonder how type(cls) != cls.__class__ is possible with new style
classes. So far I found only one way and it ain't beautiful:
class Meta(type):
... def __getattribute__(self, key):
... if key == __class__: return
Guido van Rossum added the comment:
Good work indeed!
Here's another way:
class C:
... @property
... def __class__(self): return D
...
class D: pass
...
C().__class__
class '__main__.D'
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1265
Guido van Rossum added the comment:
BTW: if you can show (e.g. with your unittest) that this indeed breaks
in 2.6 and 2.5, please do backport it.
BTW**2: I've noticed that abc.py's __instancecheck__ gets called a lot
at times when I don't expect it. Can you research this a bit?
Guido van Rossum added the comment:
PPSS. When backporting, a note in Misc/NEWS is appreciated.
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1265
__
___
Python-bugs-list
Christian Heimes added the comment:
The bug makes debugging a crux :(
--
priority: - high
resolution: - accepted
type: - behavior
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1265
__
Changes by Guido van Rossum:
--
nosy: +gvanrossum
__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1265
__
___
Python-bugs-list mailing list
Unsubscribe: