[issue39573] [C API] Make PyObject an opaque structure in the limited C API

STINNER Victor report at bugs.python.org
Tue Apr 14 21:35:27 EDT 2020


STINNER Victor <vstinner at python.org> added the comment:

PyType_FromSpec() and PyType_Spec API are not currently compatible with opaque PyObject.

Example:
---
#define PyObject_HEAD    PyObject ob_base;

typedef struct {
    PyObject_HEAD
    ...
} MyObject;

static PyType_Spec type_spec = {
    .name = "MyObject",
    .basicsize = sizeof(MyObject),
    ...
};

... = PyType_FromSpec(&type_spec);
---

sizeof(MyObject) requires to compute sizeof(PyObject).

Issue reported by Ronald Oussoren on python-dev:
https://mail.python.org/archives/list/python-dev@python.org/message/PGKRW7S2IUOWVRX6F7RT6VAWD3ZPUDYS/

----------
title: Make PyObject an opaque structure in the limited C API -> [C API] Make PyObject an opaque structure in the limited C API

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


More information about the Python-bugs-list mailing list