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 Jim Fasarakis-Hilliard
Recipients Jim Fasarakis-Hilliard
Date 2017-05-02.14:30:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1493735445.03.0.987403403044.issue30230@psf.upfronthosting.co.za>
In-reply-to
Content
Currently the first lines in PyObject_IsSubClass are:

    /* We know what type's __subclasscheck__ does. */
    if (PyType_CheckExact(cls)) {
        /* Quick test for an exact match */
        if (derived == cls)
            return 1;
        return recursive_issubclass(derived, cls);
    }

The if (derived == cls) runs only if PyType_CheckExact is True which doesn't hold for any classes with a custom metaclass. As a result, a check of the form issubclass(Sequence, Sequence) will take a slow path that invokes __subclasscheck__.

I'm not sure if this was placed inside there due to some wild edge-case, though. PyObject_IsInstance uses the same trick and does so outside the if (PyType_CheckExact(cls)) check.

I'll gladly submit a PR if this indeed needs fixing and not by design.
History
Date User Action Args
2017-05-02 14:30:45Jim Fasarakis-Hilliardsetrecipients: + Jim Fasarakis-Hilliard
2017-05-02 14:30:45Jim Fasarakis-Hilliardsetmessageid: <1493735445.03.0.987403403044.issue30230@psf.upfronthosting.co.za>
2017-05-02 14:30:44Jim Fasarakis-Hilliardlinkissue30230 messages
2017-05-02 14:30:44Jim Fasarakis-Hilliardcreate