mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
bpo-39573: Convert Py_REFCNT and Py_SIZE to functions (GH-20429)
Convert Py_REFCNT() and Py_SIZE() macros to static inline functions. They cannot be used as l-value anymore: use Py_SET_REFCNT() and Py_SET_SIZE() to set an object reference count and size. Replace &Py_SIZE(self) with &((PyVarObject*)self)->ob_size in arraymodule.c. This change is backward incompatible on purpose, to prepare the C API for an opaque PyObject structure.
This commit is contained in:
parent
20941de0dd
commit
fe2978b3b9
6 changed files with 44 additions and 14 deletions
|
@ -2525,14 +2525,14 @@ array_buffer_getbuf(arrayobject *self, Py_buffer *view, int flags)
|
|||
Py_INCREF(self);
|
||||
if (view->buf == NULL)
|
||||
view->buf = (void *)emptybuf;
|
||||
view->len = (Py_SIZE(self)) * self->ob_descr->itemsize;
|
||||
view->len = Py_SIZE(self) * self->ob_descr->itemsize;
|
||||
view->readonly = 0;
|
||||
view->ndim = 1;
|
||||
view->itemsize = self->ob_descr->itemsize;
|
||||
view->suboffsets = NULL;
|
||||
view->shape = NULL;
|
||||
if ((flags & PyBUF_ND)==PyBUF_ND) {
|
||||
view->shape = &((Py_SIZE(self)));
|
||||
view->shape = &((PyVarObject*)self)->ob_size;
|
||||
}
|
||||
view->strides = NULL;
|
||||
if ((flags & PyBUF_STRIDES)==PyBUF_STRIDES)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue