Author izbyshev
Recipients inada.naoki, izbyshev, levkivskyi, serhiy.storchaka
Date 2018-03-05.20:46:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1520282798.07.0.467229070634.issue32999@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-03-05 20:46:38izbyshevsetrecipients: + izbyshev, inada.naoki, serhiy.storchaka, levkivskyi
2018-03-05 20:46:38izbyshevsetmessageid: <1520282798.07.0.467229070634.issue32999@psf.upfronthosting.co.za>
2018-03-05 20:46:38izbyshevlinkissue32999 messages
2018-03-05 20:46:38izbyshevcreate