Inconsistent behavior of issubclass
when second argument is builtin collection
#111763
Labels
issubclass
when second argument is builtin collection
#111763
Bug report
Bug description:
Function
issubclass
requires the 1st argument to be a class (an instance oftype
). Thus, any parametrized generic cannot be passed as the first argument, because parametrized generics are instances oftypes.GenericAlias
ortyping._GenericAlias
. However, looks like this behavior depends on the seconds argument.Output
As code suggests, if the 1st arg is an instance of
types.GenericClass
and the 2nd one is builtin collection, then the result is alwaysFalse
. And if forlist
this makes sense, becauselist
is invariant, forfrozenset
the result should beTrue
asfrozenset
is covariant. However, the issue is in the absence ofTypeError
; I expect thatissubclass
always fails if the 1st argument is not an instance oftype
.If the 1st argument is a generic user class, fails as expected.
If the 2nd argument is some abstract collection, fails as expected.
If both arguments are parametrized generics, fails as expected.
I expect that
issubclass
always fails if the 1st argument is not an instance oftype
.CPython versions tested on:
3.9, 3.10, 3.11
Operating systems tested on:
Windows
The text was updated successfully, but these errors were encountered: