New submission from Anthony Sottile <asott...@umich.edu>:
This may be intentional, but the behaviour changed between python2 and python3. Want to make sure it's intentional as we're working (hacking) around this in pytest: https://github.com/pytest-dev/pytest/pull/4284 The actual impact on pytest is the use of `inspect.isclass` Simplest reproduction: class C(object): @property def __class__(self): raise AssertionError('fail') isinstance(C(), type) In python2.x: $ python2 t.py $ In python 3.x: $ python3.7 t.py Traceback (most recent call last): File "t.py", line 6, in <module> isinstance(C(), type) File "t.py", line 4, in __class__ raise AssertionError('fail') AssertionError: fail In python2.x it appears there's code which intentionally avoids this case: https://github.com/python/cpython/blob/ca079a3ea30098aff3197c559a0e32d42dda6d84/Objects/abstract.c#L2906-L2909 Mostly want to see if this is intentional or not, it does feel odd that `inspect.isclass` raises instead of returning `False` in this case, but it's unclear if it's a problem with `isclass` or `isinstance` ---------- components: Library (Lib) messages: 329078 nosy: Anthony Sottile priority: normal severity: normal status: open title: Exception in isinstance when __class__ property raises type: behavior versions: Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35137> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com