Issue2325
Created on 2008-03-17 16:45 by jyasskin, last changed 2008-05-03 00:00 by werneck.
| msg63671 (view) |
Author: Jeffrey Yasskin (jyasskin) |
Date: 2008-03-17 16:45 |
|
>>> class Meta(type):
... def __instancecheck__(self, other):
... return False
>>> isinstance(3, Meta)
In 2.6, this results in:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: maximum recursion depth exceeded while calling a Python object
(That's a recursion in C, through PyObject_IsInstance and
instancemethod_call)
In 3.0, I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __instancecheck__() takes exactly 2 positional arguments (1
given)
|
| msg66129 (view) |
Author: Pedro Werneck (werneck) |
Date: 2008-05-02 22:56 |
|
In 3.0 it happens with any class. Just the cls argument missing on the
call to instancecheck.
|
| msg66134 (view) |
Author: Pedro Werneck (werneck) |
Date: 2008-05-03 00:00 |
|
Seems like that's the wrong usage and the PEP 3119 notices that it's
hard to get the right semantics. To use it that way you need to define
the methods as a classmethod().
http://www.python.org/dev/peps/pep-3119/#one-trick-ponies
|
|
| Date |
User |
Action |
Args |
| 2008-05-03 00:00:41 | werneck | set | messages:
+ msg66134 |
| 2008-05-02 23:20:49 | werneck | set | files:
- issue2325.patch |
| 2008-05-02 22:56:52 | werneck | set | files:
+ issue2325.patch keywords:
+ patch messages:
+ msg66129 nosy:
+ werneck |
| 2008-03-17 16:45:06 | jyasskin | create | |
|