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 abarry, eryksun, gvanrossum, ppperry, r.david.murray, rhettinger, steven.daprano
Date 2016-05-30.08:08:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> why write `metatype == &PyType_Type` rather than 
> PyType_CheckExact(metatype)`?

If only `type` should implement this special case, then it needs to be `metatype == &PyType_Type`. This was actually how it was implemented in 2.2a3:

I don't know why the final release of 2.2 switched to using PyType_CheckExact, which is true for most metaclasses. That's why I feel like I'm missing something here.

Probably it used PyType_CheckExact instead of PyType_Check to ensure PyType_IsSubtype wouldn't be called. Nowadays that's optimized away via PyType_FastSubclass and the Py_TPFLAGS_TYPE_SUBCLASS flag (set up in inherit_special). If it's decided to retain this special case for metaclasses other than `type`, then I think it should use PyType_Check to consistently implement it for all metaclasses. Also, the error message should be more generic, e.g. maybe "__new__() takes 1 or 3 arguments".
Date User Action Args
2016-05-30 08:08:57eryksunsetrecipients: + eryksun, gvanrossum, rhettinger, steven.daprano, r.david.murray, ppperry, abarry
2016-05-30 08:08:57eryksunsetmessageid: <>
2016-05-30 08:08:57eryksunlinkissue27157 messages
2016-05-30 08:08:57eryksuncreate