summaryrefslogtreecommitdiffstats
path: root/Objects/bytearrayobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-02-07 22:18:08 (GMT)
committerGitHub <noreply@github.com>2020-02-07 22:18:08 (GMT)
commit60ac6ed5579f6666130fc264d3b748ee9575e3aa (patch)
treec21d06611bea34d88dd5922850223837fa6ae733 /Objects/bytearrayobject.c
parentde6f38db4859f7b8fe4da4556f06c52675fff24a (diff)
downloadcpython-60ac6ed5579f6666130fc264d3b748ee9575e3aa.zip
cpython-60ac6ed5579f6666130fc264d3b748ee9575e3aa.tar.gz
cpython-60ac6ed5579f6666130fc264d3b748ee9575e3aa.tar.bz2
bpo-39573: Use Py_SET_SIZE() function (GH-18402)
Replace direct acccess to PyVarObject.ob_size with usage of the Py_SET_SIZE() function.
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r--Objects/bytearrayobject.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index a019b49..b2808c0 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -148,7 +148,7 @@ PyByteArray_FromStringAndSize(const char *bytes, Py_ssize_t size)
memcpy(new->ob_bytes, bytes, size);
new->ob_bytes[size] = '\0'; /* Trailing null byte */
}
- Py_SIZE(new) = size;
+ Py_SET_SIZE(new, size);
new->ob_alloc = alloc;
new->ob_start = new->ob_bytes;
new->ob_exports = 0;
@@ -206,7 +206,7 @@ PyByteArray_Resize(PyObject *self, Py_ssize_t requested_size)
}
else {
/* Minor downsize; quick exit */
- Py_SIZE(self) = size;
+ Py_SET_SIZE(self, size);
PyByteArray_AS_STRING(self)[size] = '\0'; /* Trailing null */
return 0;
}
@@ -246,7 +246,7 @@ PyByteArray_Resize(PyObject *self, Py_ssize_t requested_size)
}
obj->ob_bytes = obj->ob_start = sval;
- Py_SIZE(self) = size;
+ Py_SET_SIZE(self, size);
obj->ob_alloc = alloc;
obj->ob_bytes[size] = '\0'; /* Trailing null byte */
@@ -498,7 +498,7 @@ bytearray_setslice_linear(PyByteArrayObject *self,
}
/* memmove() removed bytes, the bytearray object cannot be
restored in its previous state. */
- Py_SIZE(self) += growth;
+ Py_SET_SIZE(self, Py_SIZE(self) + growth);
res = -1;
}
buf = PyByteArray_AS_STRING(self);
@@ -886,7 +886,7 @@ bytearray_init(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
/* Append the byte */
if (Py_SIZE(self) + 1 < self->ob_alloc) {
- Py_SIZE(self)++;
+ Py_SET_SIZE(self, Py_SIZE(self) + 1);
PyByteArray_AS_STRING(self)[Py_SIZE(self)] = '\0';
}
else if (PyByteArray_Resize((PyObject *)self, Py_SIZE(self)+1) < 0)