From 60190c30effa0f5b47ac16c2dd66dbc4de71be38 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 4 Jan 2021 22:16:02 +0100 Subject: use Py_RETURN_NONE macro Signed-off-by: Giampaolo Rodola --- psutil/_psutil_common.c | 3 +-- psutil/_psutil_posix.c | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/psutil/_psutil_common.c b/psutil/_psutil_common.c index 5ebefd15..0c760c49 100644 --- a/psutil/_psutil_common.c +++ b/psutil/_psutil_common.c @@ -188,8 +188,7 @@ PyObject * psutil_set_testing(PyObject *self, PyObject *args) { PSUTIL_TESTING = 1; PSUTIL_DEBUG = 1; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff --git a/psutil/_psutil_posix.c b/psutil/_psutil_posix.c index c992e79c..488f30e9 100644 --- a/psutil/_psutil_posix.c +++ b/psutil/_psutil_posix.c @@ -229,8 +229,7 @@ psutil_convert_ipaddr(struct sockaddr *addr, int family) { char *ptr; if (addr == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else if (family == AF_INET || family == AF_INET6) { if (family == AF_INET) @@ -245,8 +244,7 @@ psutil_convert_ipaddr(struct sockaddr *addr, int family) { // ifconfig does not show anything BTW. // PyErr_Format(PyExc_RuntimeError, gai_strerror(err)); // return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { return Py_BuildValue("s", buf); @@ -269,8 +267,7 @@ psutil_convert_ipaddr(struct sockaddr *addr, int family) { #endif else { // unknown family - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } // AF_PACKET or AF_LINK @@ -284,8 +281,7 @@ psutil_convert_ipaddr(struct sockaddr *addr, int family) { return Py_BuildValue("s", buf); } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } -- cgit v1.2.1