summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-11-23 13:27:38 (GMT)
committerGitHub <noreply@github.com>2018-11-23 13:27:38 (GMT)
commitb509d52083e156f97d6bd36f2f894a052e960f03 (patch)
treee1df9b8a25b5bffccf4d20ef0a08487bab5def64 /Include
parent353933e712b6c7f7ba9a9a50bd5bd472db7c35d0 (diff)
downloadcpython-b509d52083e156f97d6bd36f2f894a052e960f03.zip
cpython-b509d52083e156f97d6bd36f2f894a052e960f03.tar.gz
cpython-b509d52083e156f97d6bd36f2f894a052e960f03.tar.bz2
bpo-35059: PyObject_INIT() casts to PyObject* (GH-10674)
PyObject_INIT() and PyObject_INIT_VAR() now cast their first argument to PyObject*, as done in Python 3.7. Revert partially commit b4435e20a92af474f117b78b98ddc6f515363af5.
Diffstat (limited to 'Include')
-rw-r--r--Include/objimpl.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/Include/objimpl.h b/Include/objimpl.h
index 1c50d8b..aee3fdc 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -145,7 +145,7 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
These inline functions expect non-NULL object pointers. */
static inline PyObject*
-PyObject_INIT(PyObject *op, PyTypeObject *typeobj)
+_PyObject_INIT(PyObject *op, PyTypeObject *typeobj)
{
assert(op != NULL);
Py_TYPE(op) = typeobj;
@@ -153,8 +153,11 @@ PyObject_INIT(PyObject *op, PyTypeObject *typeobj)
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)
+_PyObject_INIT_VAR(PyVarObject *op, PyTypeObject *typeobj, Py_ssize_t size)
{
assert(op != NULL);
Py_SIZE(op) = size;
@@ -162,6 +165,9 @@ PyObject_INIT_VAR(PyVarObject *op, PyTypeObject *typeobj, Py_ssize_t size)
return op;
}
+#define PyObject_INIT_VAR(op, typeobj, size) \
+ _PyObject_INIT_VAR(_PyVarObject_CAST(op), (typeobj), (size))
+
#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize )
/* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a