diff options
author | Victor Stinner <vstinner@python.org> | 2020-03-06 14:55:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-06 14:55:14 (GMT) |
commit | 1fb5a9f394a6fdf62e21b96080c3257c959cf8c9 (patch) | |
tree | 12ce1e28d5b4de89c85377168a214442319d9c35 /Objects/object.c | |
parent | 7598a93139a8d76a331d5f30121277031044d35b (diff) | |
download | cpython-1fb5a9f394a6fdf62e21b96080c3257c959cf8c9.zip cpython-1fb5a9f394a6fdf62e21b96080c3257c959cf8c9.tar.gz cpython-1fb5a9f394a6fdf62e21b96080c3257c959cf8c9.tar.bz2 |
bpo-39873: PyObject_Init() uses PyObject_INIT() (GH-18804)
Avoid duplicated code:
* PyObject_Init() uses PyObject_INIT()
* PyObject_InitVar() uses PyObject_INIT_VAR()
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/Objects/object.c b/Objects/object.c index 9c74e07..707424c 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -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 * |