From ba86008aac6890c5c4a2c6d30ea8110f228d483e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 20 Nov 2016 12:16:46 +0200 Subject: Issue #19569: Compiler warnings are now emitted if use most of deprecated functions. --- Modules/arraymodule.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Modules/arraymodule.c') diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 2caa8ee5a8..a68db18b0f 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -236,7 +236,7 @@ BB_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) static PyObject * u_getitem(arrayobject *ap, Py_ssize_t i) { - return PyUnicode_FromUnicode(&((Py_UNICODE *) ap->ob_item)[i], 1); + return PyUnicode_FromOrdinal(((Py_UNICODE *) ap->ob_item)[i]); } static int @@ -1693,7 +1693,7 @@ array_array_tounicode_impl(arrayobject *self) "tounicode() may only be called on unicode type arrays"); return NULL; } - return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_SIZE(self)); + return PyUnicode_FromWideChar((Py_UNICODE *) self->ob_item, Py_SIZE(self)); } /*[clinic input] -- cgit v1.2.1 From e29cd26d1dfebb2d8ba06fdad88223dec0762cba Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 9 Dec 2016 16:09:30 +0100 Subject: Use _PyObject_CallMethodIdObjArgs() Issue #28915: Replace _PyObject_CallMethodId() with _PyObject_CallMethodIdObjArgs() in various modules when the format string was only made of "O" formats, PyObject* arguments. _PyObject_CallMethodIdObjArgs() avoids the creation of a temporary tuple and doesn't have to parse a format string. --- Modules/arraymodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Modules/arraymodule.c') diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index a68db18b0f..f1469df4c9 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1445,7 +1445,7 @@ array_array_tofile(arrayobject *self, PyObject *f) bytes = PyBytes_FromStringAndSize(ptr, size); if (bytes == NULL) return NULL; - res = _PyObject_CallMethodId(f, &PyId_write, "O", bytes); + res = _PyObject_CallMethodIdObjArgs(f, &PyId_write, bytes, NULL); Py_DECREF(bytes); if (res == NULL) return NULL; -- cgit v1.2.1 From bfeec6d871e3db2e0ddfdef01387913bc19cadd4 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 23 Jan 2017 09:47:21 +0200 Subject: Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever possible. Patch is writen with Coccinelle. --- Modules/arraymodule.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'Modules/arraymodule.c') diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index f1469df4c9..464820d2af 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1007,8 +1007,7 @@ ins(arrayobject *self, Py_ssize_t where, PyObject *v) { if (ins1(self, where, v) != 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1122,8 +1121,7 @@ array_array_remove(arrayobject *self, PyObject *v) if (cmp > 0) { if (array_del_slice(self, i, i+1) != 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else if (cmp < 0) return NULL; @@ -1185,8 +1183,7 @@ array_array_extend(arrayobject *self, PyObject *bb) { if (array_do_extend(self, bb) == -1) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1315,8 +1312,7 @@ array_array_byteswap_impl(arrayobject *self) "don't know how to byteswap this array type"); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1349,8 +1345,7 @@ array_array_reverse_impl(arrayobject *self) } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1453,8 +1448,7 @@ array_array_tofile(arrayobject *self, PyObject *f) } done: - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1491,8 +1485,7 @@ array_array_fromlist(arrayobject *self, PyObject *list) } } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1557,8 +1550,7 @@ frombytes(arrayobject *self, Py_buffer *buffer) buffer->buf, n * itemsize); } PyBuffer_Release(buffer); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] -- cgit v1.2.1