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

I do not see any point in allowing non-types in ABCMeta.__subclasscheck__. 
Currently, ABCs are clearly not designed to support non-types:

1. ABCMeta.register() accepts types only.
2. ABCMeta.__subclasscheck__ implicitly requires its arguments to support weak 
references (regardless of whether __subclasshook__ is called or not). This 
requirement alone doesn't make sense, so it seems to be an exposed 
implementation detail stemming from the fact that non-types were not intended 
to be supported.
3. Some ABC users already expect that the argument of __subclasshook__ is a 
type (see the example with collections.abc.Reversible by OP).
4. Attempting to support arbitrary arguments in ABC.__subclasscheck__ (by 
returning False instead of raising TypeError or worse) will not solve any 
'issubclass' inconsistencies. 'issubclass' is fundamentally "fragmented": 
issubclass(x, y) may return True/False while issubclass(x, z) may raise 
TypeError, depending on __subclasscheck__ implementation. It may be too late to 
impose stricter requirements for the first argument of issubclass because 
'typing' module relies on the support of non-types there.

----------

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

Reply via email to