Alexey Izbyshev <izbys...@ispras.ru> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32999>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to