summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-07 22:38:15 (GMT)
committerGitHub <noreply@github.com>2020-04-07 22:38:15 (GMT)
commit9205520d8c43488696d66cbdd9aefbb21871c508 (patch)
tree6c6d03828fddd763f261d89a9afef18b109c0d3d /Objects
parentf9dd51e7db27d04e0b716d41a2804d5acbf145d1 (diff)
downloadcpython-9205520d8c43488696d66cbdd9aefbb21871c508.zip
cpython-9205520d8c43488696d66cbdd9aefbb21871c508.tar.gz
cpython-9205520d8c43488696d66cbdd9aefbb21871c508.tar.bz2
bpo-40170: PyObject_NEW() becomes an alias to PyObject_New() (GH-19379)
The PyObject_NEW() macro becomes an alias to the PyObject_New() macro, and the PyObject_NEW_VAR() macro becomes an alias to the PyObject_NewVar() macro, to hide implementation details. They no longer access directly the PyTypeObject.tp_basicsize member. Exclude _PyObject_SIZE() and _PyObject_VAR_SIZE() macros from the limited C API. Replace PyObject_NEW() with PyObject_New() and replace PyObject_NEW_VAR() with PyObject_NewVar().
Diffstat (limited to 'Objects')
-rw-r--r--Objects/capsule.c2
-rw-r--r--Objects/codeobject.c2
-rw-r--r--Objects/object.c9
3 files changed, 7 insertions, 6 deletions
diff --git a/Objects/capsule.c b/Objects/capsule.c
index 599893a..ed24cc1 100644
--- a/Objects/capsule.c
+++ b/Objects/capsule.c
@@ -50,7 +50,7 @@ PyCapsule_New(void *pointer, const char *name, PyCapsule_Destructor destructor)
return NULL;
}
- capsule = PyObject_NEW(PyCapsule, &PyCapsule_Type);
+ capsule = PyObject_New(PyCapsule, &PyCapsule_Type);
if (capsule == NULL) {
return NULL;
}
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index fd64393..1820d8c 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -219,7 +219,7 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
cell2arg = NULL;
}
}
- co = PyObject_NEW(PyCodeObject, &PyCode_Type);
+ co = PyObject_New(PyCodeObject, &PyCode_Type);
if (co == NULL) {
if (cell2arg)
PyMem_FREE(cell2arg);
diff --git a/Objects/object.c b/Objects/object.c
index 05241e8..069afc0 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -161,11 +161,12 @@ PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, Py_ssize_t size)
PyObject *
_PyObject_New(PyTypeObject *tp)
{
- PyObject *op;
- op = (PyObject *) PyObject_MALLOC(_PyObject_SIZE(tp));
- if (op == NULL)
+ PyObject *op = (PyObject *) PyObject_MALLOC(_PyObject_SIZE(tp));
+ if (op == NULL) {
return PyErr_NoMemory();
- return PyObject_INIT(op, tp);
+ }
+ PyObject_INIT(op, tp);
+ return op;
}
PyVarObject *