From 3c805bea1500211785fddd8069a4dcd6633880da Mon Sep 17 00:00:00 2001 From: Alberto Planas Date: Tue, 24 Oct 2023 15:16:38 +0200 Subject: [PATCH] Raise an exception when returning NULL Signed-off-by: Alberto Planas --- psutil/arch/linux/users.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/psutil/arch/linux/users.c b/psutil/arch/linux/users.c index 0c23b947eb..16b968ead9 100644 --- a/psutil/arch/linux/users.c +++ b/psutil/arch/linux/users.c @@ -163,6 +163,7 @@ psutil_users_systemd(PyObject *self, PyObject *args) { Py_DECREF(py_retlist); if (sessions_list) free(sessions_list); + PyErr_SetString(PyExc_RuntimeError, "cannot get user information via systemd"); return NULL; } @@ -223,5 +224,6 @@ psutil_users_utmp(PyObject *self, PyObject *args) { Py_XDECREF(py_tuple); Py_DECREF(py_retlist); endutent(); + PyErr_SetString(PyExc_RuntimeError, "cannot get user information via utmp"); return NULL; }