[pypy-issue] Issue #2343: PyPy hides TypeError raised by __instancecheck__ (pypy/pypy)
Michael Amrhein
issues-reply at bitbucket.org
Tue Jul 12 09:56:33 EDT 2016
New issue 2343: PyPy hides TypeError raised by __instancecheck__
https://bitbucket.org/pypy/pypy/issues/2343/pypy-hides-typeerror-raised-by
Michael Amrhein:
```
#!python
Python 2.7.10 (7e8df3df96417c16c2d55b41352ec82c9c69c978, Jul 09 2016, 13:13:39)
[PyPy 5.3.1 with GCC 4.9.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> class AnyMeta(type):
.... def __instancecheck__(cls, obj):
.... raise TypeError("'Any' cannot be used with isinstance().")
....
>>>> class Any(object):
.... __metaclass__ = AnyMeta
....
>>>> Any.__instancecheck__(42)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in __instancecheck__
TypeError: 'Any' cannot be used with isinstance().
```
but
```
#!python
>>>> isinstance(42, Any)
False
```
More information about the pypy-issue
mailing list