Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-39873: PyObject_Init() uses PyObject_INIT()
Avoid duplicated code:

* PyObject_Init() uses PyObject_INIT()
* PyObject_InitVar() uses PyObject_INIT_VAR()
  • Loading branch information
vstinner committed Mar 6, 2020
commit ad0c31b7bc36c6c5dac3158efc2af3cfb8d9fde0
11 changes: 2 additions & 9 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand All @@ -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 *
Expand Down