This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Guido.van.Rossum, gvanrossum, larry, lukasz.langa, r.david.murray, vstinner
Date 2015-09-04.07:52:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1441353174.49.0.445300515046.issue24635@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-09-04 07:52:54vstinnersetrecipients: + vstinner, gvanrossum, larry, r.david.murray, lukasz.langa, Guido.van.Rossum
2015-09-04 07:52:54vstinnersetmessageid: <1441353174.49.0.445300515046.issue24635@psf.upfronthosting.co.za>
2015-09-04 07:52:54vstinnerlinkissue24635 messages
2015-09-04 07:52:53vstinnercreate