diff options
| author | Victor Stinner <vstinner@python.org> | 2020-06-16 01:28:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-16 01:28:07 +0200 |
| commit | 04fc4f2a46b2fd083639deb872c3a3037fdb47d6 (patch) | |
| tree | 3fc5a585683e09748fb3113c34cfa42e8bf634b2 /Include/cpython/objimpl.h | |
| parent | 7ab92d54b5d4440d84f6c02b4bc5a70103eff915 (diff) | |
| download | cpython-git-04fc4f2a46b2fd083639deb872c3a3037fdb47d6.tar.gz | |
bpo-40989: PyObject_INIT() becomes an alias to PyObject_Init() (GH-20901)
The PyObject_INIT() and PyObject_INIT_VAR() macros become aliases to,
respectively, PyObject_Init() and PyObject_InitVar() functions.
Rename _PyObject_INIT() and _PyObject_INIT_VAR() static inline
functions to, respectively, _PyObject_Init() and _PyObject_InitVar(),
and move them to pycore_object.h. Remove their return value:
their return type becomes void.
The _datetime module is now built with the Py_BUILD_CORE_MODULE macro
defined.
Remove an outdated comment on _Py_tracemalloc_config.
Diffstat (limited to 'Include/cpython/objimpl.h')
| -rw-r--r-- | Include/cpython/objimpl.h | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/Include/cpython/objimpl.h b/Include/cpython/objimpl.h index ca4009bcdb..15999a239f 100644 --- a/Include/cpython/objimpl.h +++ b/Include/cpython/objimpl.h @@ -37,8 +37,9 @@ PyObject *op; op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct)); - if (op == NULL) - return PyErr_NoMemory(); + if (op == NULL) { + return PyErr_NoMemory(); + } PyObject_Init(op, &YourTypeStruct); @@ -51,40 +52,6 @@ the 1st step is performed automatically for you, so in a C++ class constructor you would start directly with PyObject_Init/InitVar. */ - -/* Inline functions trading binary compatibility for speed: - PyObject_INIT() is the fast version of PyObject_Init(), and - PyObject_INIT_VAR() is the fast version of PyObject_InitVar(). - - These inline functions must not be called with op=NULL. */ -static inline PyObject* -_PyObject_INIT(PyObject *op, PyTypeObject *typeobj) -{ - assert(op != NULL); - Py_SET_TYPE(op, typeobj); - if (PyType_GetFlags(typeobj) & Py_TPFLAGS_HEAPTYPE) { - Py_INCREF(typeobj); - } - _Py_NewReference(op); - return op; -} - -#define PyObject_INIT(op, typeobj) \ - _PyObject_INIT(_PyObject_CAST(op), (typeobj)) - -static inline PyVarObject* -_PyObject_INIT_VAR(PyVarObject *op, PyTypeObject *typeobj, Py_ssize_t size) -{ - assert(op != NULL); - Py_SET_SIZE(op, size); - PyObject_INIT((PyObject *)op, typeobj); - return op; -} - -#define PyObject_INIT_VAR(op, typeobj, size) \ - _PyObject_INIT_VAR(_PyVarObject_CAST(op), (typeobj), (size)) - - /* This function returns the number of allocated memory blocks, regardless of size */ PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void); |
