Message249735
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. |
|
| Date |
User |
Action |
Args |
| 2015-09-04 07:52:54 | vstinner | set | recipients:
+ vstinner, gvanrossum, larry, r.david.murray, lukasz.langa, Guido.van.Rossum |
| 2015-09-04 07:52:54 | vstinner | set | messageid: <1441353174.49.0.445300515046.issue24635@psf.upfronthosting.co.za> |
| 2015-09-04 07:52:54 | vstinner | link | issue24635 messages |
| 2015-09-04 07:52:53 | vstinner | create | |
|