[issue33018] Improve issubclass() error checking and message
Alexey Izbyshev
report at bugs.python.org
Thu Mar 8 09:30:46 EST 2018
Alexey Izbyshev <izbyshev at ispras.ru> added the comment:
> Isn't it just a limitation?
> Most Python-implemented objects supports weakref. I don't think "requiring weakref support implies it must be type object".
Formally, there is no implication. It is the abc module authors who know the truth. But I can't imagine why anybody would impose such a limitation by design, because while instances of user-defined classes support weakrefs, built-in classes used by everybody like tuple, list and dict don't. That's why I guessed that non-types were not meant to be supported.
> What "by OP" means?
OP = Original poster (@jab).
> I can't find `if not issubclass(cls, type): raise TypeError` in Reversible implementation.
> They do duck-typing, same to ABC.
Sorry for being unclear. There is no explicit check as you say, but __mro__ is directly accessed (see msg313376). But it may probably be considered "duck typing" too.
> But I don't know much about how mages use ABC. I need mages comment before merging the pull request.
Totally agree.
> BTW, do you think it should be backported to 3.7, or even 3.6?
3.7 certainly has my vote -- this can hardly be considered a new feature.
For 3.6, I'd listen to ABC users/experts. Might raising a TypeError instead of returning False from issubclass(user_defined_obj, ABC) break something important? Personally, I think it would mostly expose bugs and not hinder reasonable usage.
> Can https://github.com/python/cpython/commit/fc7df0e664198cb05cafd972f190a18ca422989c be reverted?
Seems like it can, but the test should survive in some form :)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33018>
_______________________________________
More information about the Python-bugs-list
mailing list