Ken Jin <kenjin4...@gmail.com> added the comment:

@Paul, Steve, Tim and Zach, I've removed y'all from nosy as this isn't a 
Windows issue (but a typing/builtin types one). If you feel that I shouldn't 
have done that: my apologies and please do tell me.

To summarize what OP said:

>>> isinstance(bool, (bool, list[bool]))
TypeError: isinstance() argument 2 cannot be a parameterized generic

>>> issubclass(bool, (bool, list[bool]))
True

@OP, this seems like a bug. issubclass should raise according to PEP 585. In 
this case it's short-circuiting so it doesn't check the 2nd arg. Swapping the 
arguments around gives the expected TypeError.

>>> issubclass(bool, (list[bool], bool))
TypeError: issubclass() argument 2 cannot be a parameterized generic

At the same time, I'm hesitant to run a check through everything in the types 
tuple first. That would hurt issubclass performance (I'm not sure by how much). 
What do you think, Guido and Serhiy?

----------
components: +Library (Lib) -Tests, Windows
nosy: +gvanrossum, kj, serhiy.storchaka -paul.moore, steve.dower, tim.golden, 
zach.ware
versions: +Python 3.11, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44932>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to