STINNER Victor added the comment: Ok, I found a short script to reproduce the bug: -- import typing: assert isinstance([], typing.Container) assert isinstance([], typing.Container) --
The first check calls typing.GenericMeta.__subclasscheck__(list) which calls abc.ABCMeta.__subclasscheck__(typing.Container, list). The problem is that not only abc.ABCMeta.__subclasscheck__() returns False, but it adds also list to typing.Container._abc_negative_cache. The next check returns False without calling typing.GenericMeta.__subclasscheck__(list), in fact ABCMeta.__instancecheck__(typing.GenericMeta, list) returns immediatly False because list is in typing.Container._abc_negative_cache. The problem: GenericMeta calls ABCMeta.__subclasscheck__() which returns False, but ABCMeta.__subclasscheck__() also stores the result "False" in cache, whereas it's not the expected result. Should we override __instancecheck__ in GenericMeta? @Guido: are you interested to fix this complex metaclass/type issue? I don't have time to fix it right now. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24635> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com