Message235852
Given super(cls, obj), cls needs to be somewhere in type(obj).__mro__. Thus the implementation checks PyType_IsSubtype instead of the more generic PyObject_IsSubclass.
In this case int's MRO is unrelated to numbers.Number:
>>> print(*int.__mro__, sep='\n')
<class 'int'>
<class 'object'>
It gets registered as a subclass via numbers.Integral.register(int).
>>> print(*numbers.Integral._abc_registry)
<class 'int'>
issubclass calls PyObject_IsSubclass, which uses the __subclasscheck__ API. In this case ABCMeta.__subclasscheck__ recursively checks the registry and caches the result to speed up future checks.
>>> numbers.Number.__subclasscheck__(int)
True
>>> print(*numbers.Number._abc_cache)
<class 'int'> |
|
Date |
User |
Action |
Args |
2015-02-12 19:28:51 | eryksun | set | recipients:
+ eryksun, rhettinger, Gerrit.Holl |
2015-02-12 19:28:51 | eryksun | set | messageid: <1423769331.67.0.286264431874.issue20503@psf.upfronthosting.co.za> |
2015-02-12 19:28:51 | eryksun | link | issue20503 messages |
2015-02-12 19:28:51 | eryksun | create | |
|