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 eryksun
Recipients Gerrit.Holl, eryksun, rhettinger
Date 2015-02-12.19:28:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1423769331.67.0.286264431874.issue20503@psf.upfronthosting.co.za>
In-reply-to
Content
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'>
History
Date User Action Args
2015-02-12 19:28:51eryksunsetrecipients: + eryksun, rhettinger, Gerrit.Holl
2015-02-12 19:28:51eryksunsetmessageid: <1423769331.67.0.286264431874.issue20503@psf.upfronthosting.co.za>
2015-02-12 19:28:51eryksunlinkissue20503 messages
2015-02-12 19:28:51eryksuncreate