summaryrefslogtreecommitdiffstats
path: root/Modules/arraymodule.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2017-09-14 04:20:29 (GMT)
committerGitHub <noreply@github.com>2017-09-14 04:20:29 (GMT)
commita72d15c97f9837f6c9c6bd476a62175c942cc588 (patch)
tree104b0a1b090a9743e3efcdeae924c3ac9e306f12 /Modules/arraymodule.c
parent860839cc8e0a4a0890418f77c984955697f96828 (diff)
downloadcpython-a72d15c97f9837f6c9c6bd476a62175c942cc588.zip
cpython-a72d15c97f9837f6c9c6bd476a62175c942cc588.tar.gz
cpython-a72d15c97f9837f6c9c6bd476a62175c942cc588.tar.bz2
consistently use Py_TYPE, Py_REFCNT, and correct initializer macros (#3563)
This no-op change makes 2.7 more consistent with 3.x to ease comparison and backports.
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r--Modules/arraymodule.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index f6f597a..5bd3a42 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1292,9 +1292,9 @@ array_tofile(arrayobject *self, PyObject *f)
PyErr_SetString(PyExc_TypeError, "arg must be open file");
return NULL;
}
- if (self->ob_size > 0) {
+ if (Py_SIZE(self) > 0) {
if (fwrite(self->ob_item, self->ob_descr->itemsize,
- self->ob_size, fp) != (size_t)self->ob_size) {
+ Py_SIZE(self), fp) != (size_t)Py_SIZE(self)) {
PyErr_SetFromErrno(PyExc_IOError);
clearerr(fp);
return NULL;
@@ -1348,7 +1348,7 @@ array_fromlist(arrayobject *self, PyObject *list)
if ((*self->ob_descr->setitem)(self,
Py_SIZE(self) - n + i, v) != 0) {
Py_SIZE(self) -= n;
- if (itemsize && (self->ob_size > PY_SSIZE_T_MAX / itemsize)) {
+ if (itemsize && (Py_SIZE(self) > PY_SSIZE_T_MAX / itemsize)) {
return PyErr_NoMemory();
}
PyMem_RESIZE(item, char,
@@ -1444,7 +1444,7 @@ values,as if it had been read from a file using the fromfile() method).");
static PyObject *
array_tostring(arrayobject *self, PyObject *unused)
{
- if (self->ob_size <= PY_SSIZE_T_MAX / self->ob_descr->itemsize) {
+ if (Py_SIZE(self) <= PY_SSIZE_T_MAX / self->ob_descr->itemsize) {
return PyString_FromStringAndSize(self->ob_item,
Py_SIZE(self) * self->ob_descr->itemsize);
} else {
@@ -2289,8 +2289,8 @@ initarray(void)
{
PyObject *m;
- Arraytype.ob_type = &PyType_Type;
- PyArrayIter_Type.ob_type = &PyType_Type;
+ Py_TYPE(&Arraytype) = &PyType_Type;
+ Py_TYPE(&PyArrayIter_Type) = &PyType_Type;
m = Py_InitModule3("array", a_methods, module_doc);
if (m == NULL)
return;