mirror of
https://github.com/python/cpython
synced 2026-09-29 10:10:30 +03:00
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 b4435e20a9.
This commit is contained in:
parent
353933e712
commit
b509d52083
8 changed files with 18 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue