bpo-39873: PyObject_Init() uses PyObject_INIT() (GH-18804)

Avoid duplicated code:

* PyObject_Init() uses PyObject_INIT()
* PyObject_InitVar() uses PyObject_INIT_VAR()
This commit is contained in:
Victor Stinner 2020-03-06 15:55:14 +01:00 committed by GitHub
parent 7598a93139
commit 1fb5a9f394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 9 deletions

View File

@ -144,12 +144,7 @@ PyObject_Init(PyObject *op, PyTypeObject *tp)
return PyErr_NoMemory();
}
Py_SET_TYPE(op, tp);
if (PyType_GetFlags(tp) & Py_TPFLAGS_HEAPTYPE) {
Py_INCREF(tp);
}
_Py_NewReference(op);
return op;
return PyObject_INIT(op, tp);
}
PyVarObject *
@ -160,9 +155,7 @@ PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, Py_ssize_t size)
return (PyVarObject *) PyErr_NoMemory();
}
Py_SET_SIZE(op, size);
PyObject_Init((PyObject *)op, tp);
return op;
return PyObject_INIT_VAR(op, tp, size);
}
PyObject *