[issue44932] `issubclass` and `isinstance` doesn't check for all 2nd argument types

Serhiy Storchaka report at bugs.python.org
Tue Aug 17 07:17:31 EDT 2021


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

It is not specific to typing.

>>> isinstance(1, (int, 1))
True
>>> isinstance(1, (1, int))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: isinstance() arg 2 must be a type or tuple of types
>>> issubclass(int, (int, 1))
True
>>> issubclass(int, (1, int))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: issubclass() arg 2 must be a class or tuple of classes

isinstance() and issubclass() with tuples always stopped on first positive match. I don't think there is need to change this.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44932>
_______________________________________


More information about the Python-bugs-list mailing list