[issue15870] PyType_FromSpec should take metaclass as an argument

Josh Haberman report at bugs.python.org
Thu Sep 23 14:53:55 EDT 2021


Josh Haberman <haberman at google.com> added the comment:

> Passing the metaclass as a slot seems like the right idea for this API, though I recall there being some concern about the API (IIRC, mixing function pointers and data pointers doesn't work on some platforms?)

PyType_Slot is defined as a void* (not a function pointer): https://github.com/python/cpython/blob/8492b729ae97737d22544f2102559b2b8dd03a03/Include/object.h#L223-L226

So putting a PyTypeObject* into a slot would appear to be more kosher than function pointers.

Overall, a slot seems like a great first approach.  It doesn't require any new functions, which seems like a plus.  If the any linking issues a la tp_base are seen, a new function could be added later.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue15870>
_______________________________________


More information about the Python-bugs-list mailing list