[New-bugs-announce] [issue2325] isinstance(anything, MetaclassThatDefinesInstancecheck) raises instead of returning False

Jeffrey Yasskin report at bugs.python.org
Mon Mar 17 17:45:06 CET 2008


New submission from Jeffrey Yasskin <jyasskin at gmail.com>:

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

----------
components: Interpreter Core
messages: 63671
nosy: jyasskin
severity: normal
status: open
title: isinstance(anything, MetaclassThatDefinesInstancecheck) raises instead of returning False
type: behavior
versions: Python 2.6, Python 3.0

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2325>
__________________________________


More information about the New-bugs-announce mailing list