Message313284
I've also checked that ABC.register() doesn't allow non-classes (and PEP 3119 mentions that).
Looking at PyObject_IsSubclass in Objects/abstract.c, the only case in which its check_class() could be avoided is if there is a custom __subclasscheck__:
>>> class M(type):
... def __subclasscheck__(cls, c):
... return c == 1 or super().__subclasscheck__(c)
...
>>> class A(metaclass=M):
... pass
...
>>> issubclass(1, A)
True
If there is no need to support such weird __subclasscheck__, check_class() could be called earlier.
Note, however, that check_class() treats anything having __bases__ as a class, so moving the check alone is not enough to avoid the crash in all cases. |
|
Date |
User |
Action |
Args |
2018-03-05 20:46:38 | izbyshev | set | recipients:
+ izbyshev, methane, serhiy.storchaka, levkivskyi |
2018-03-05 20:46:38 | izbyshev | set | messageid: <1520282798.07.0.467229070634.issue32999@psf.upfronthosting.co.za> |
2018-03-05 20:46:38 | izbyshev | link | issue32999 messages |
2018-03-05 20:46:38 | izbyshev | create | |
|