Message11090

Author stefan.richthofer
Recipients asmeurer, stefan.richthofer
Date 2017-02-08.21:46:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1486590362.45.0.369096689529.issue2551@psf.upfronthosting.co.za>
In-reply-to
Content
After some digging I'm convinced the problem lies in PyType and is about detection of what is called a solid base. I.e. a class defining __slots__ = () shall actually not be considered a solid base, but currently is. A proper solid base would have to actually add a slot, not set slots to an empty sequence. Solid bases are detected based on numSlots, which would normally be 0 if slots is an empty sequence. However in the example numSlots would be 1 because of the parent class.

I would modify

private static boolean isSolidBase(PyType type) {
        return type.underlying_class != null || (type.numSlots != 0 && !type.needs_userdict);
}

such that it doesn't rely on absolute numSlots value but on the difference to base's numSlots. So to be a solid base it must actually *introduce* a slot, not just *have* a slot from base or so.

Proposed change:

private static boolean isSolidBase(PyType type) {
    return type.underlying_class != null || (type.numSlots - (type.base != null ? type.base.numSlots : 0) != 0 && !type.needs_userdict);
}
History
Date User Action Args
2017-02-08 21:46:02stefan.richthofersetmessageid: <1486590362.45.0.369096689529.issue2551@psf.upfronthosting.co.za>
2017-02-08 21:46:02stefan.richthofersetrecipients: + stefan.richthofer, asmeurer
2017-02-08 21:46:02stefan.richthoferlinkissue2551 messages
2017-02-08 21:46:02stefan.richthofercreate