This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients gvanrossum, kj, serhiy.storchaka
Date 2021-10-29.08:41:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1635496883.97.0.0425053445478.issue45665@roundup.psfhosted.org>
In-reply-to
Content
isinstance(x, type) returns True for instances of types.GenericAlias (like list[int]). While it may help in some cases related to typing, in many unrelated cases it causes problems if the value which is not a type passes checks for types.

Also, isinstance(x, type) been not equal to issubclass(type(x), type) can cause other problems. No matter what the result should be, it should be consistent.

There are many occurrences of isinstance(..., type) in the code.

$ find Lib -name '*.py' \! -path '*/test*' -exec egrep 'isinstance.*,
type\)' '{}' + | wc -l
55

And all of them can potentially be broken if pass a types.GenericAlias instance. Many of them are safe, but every case should be analyzed.
History
Date User Action Args
2021-10-29 08:41:24serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, kj
2021-10-29 08:41:23serhiy.storchakasetmessageid: <1635496883.97.0.0425053445478.issue45665@roundup.psfhosted.org>
2021-10-29 08:41:23serhiy.storchakalinkissue45665 messages
2021-10-29 08:41:23serhiy.storchakacreate