Message405161
> issubclass(x, list[int]) rejects the second argument for reasons explained in the PEP.
1. One problem is that isinstance(x, type) != issubclass(type(x), type)
if x is list[int]. It is unprecedented, I cannot recall any other case
in which isinstance() and issubclas() are inconsistent. Ant it breaks
code because these two expressions are often considered equivalent and
interchangeable in refactoring.
2. Other problem is that isinstance(x, type) is used as a guard before
using x as a type. `isinstance(obj, type) and issubclass(obj,
SomeClass)` is a common idiom, because issubclass() raises an exception
if its first argument is not a type. It is now broken for list[int].
> What other places are there that are broken because of this?
$ find Lib -name '*.py' \! -path '*/test*' -exec egrep 'isinstance.*,
type\)' '{}' + | wc -l
55
In msg403826 I showed few examples from just two files, but there are
tens more potential examples. I'll show them all if I have enough of
spare time. |
|
Date |
User |
Action |
Args |
2021-10-28 08:44:35 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, rhettinger, levkivskyi, miss-islington, kj, martinitus |
2021-10-28 08:44:35 | serhiy.storchaka | set | messageid: <1635410675.06.0.386270634215.issue45438@roundup.psfhosted.org> |
2021-10-28 08:44:35 | serhiy.storchaka | link | issue45438 messages |
2021-10-28 08:44:34 | serhiy.storchaka | create | |
|