BUG/MAJOR: spoa/python: Fixing return None
authorGilchrist Dadaglo <dadaglo@amazon.com>
Tue, 8 Dec 2020 14:37:07 +0000 (14:37 +0000)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 14 Dec 2020 10:43:25 +0000 (11:43 +0100)
As per https://docs.python.org/3/c-api/none.html, None requires to be
incremented before being returned to prevent deallocating none

This patch must be backported as far as 2.0.

(cherry picked from commit d5c428e761796317fdfa9c7f9bf3f6280e218a98)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit bd9abd2ca8246ef37225485298af9f59831e3af3)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 1c6e7507d646c165c31de4ca46034237b249ef83)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

contrib/spoa_server/ps_python.c

index 433e4c5..b72b7e7 100644 (file)
@@ -54,7 +54,7 @@ static PyObject *ps_python_register_message(PyObject *self, PyObject *args)
 
        ps_register_message(&ps_python_bindings, name, (void *)ref);
 
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *ps_python_set_var_null(PyObject *self, PyObject *args)
@@ -69,7 +69,7 @@ static PyObject *ps_python_set_var_null(PyObject *self, PyObject *args)
                PyErr_SetString(spoa_error, "No space left available");
                return NULL;
        }
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *ps_python_set_var_boolean(PyObject *self, PyObject *args)
@@ -85,7 +85,7 @@ static PyObject *ps_python_set_var_boolean(PyObject *self, PyObject *args)
                PyErr_SetString(spoa_error, "No space left available");
                return NULL;
        }
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *ps_python_set_var_int32(PyObject *self, PyObject *args)
@@ -101,7 +101,7 @@ static PyObject *ps_python_set_var_int32(PyObject *self, PyObject *args)
                PyErr_SetString(spoa_error, "No space left available");
                return NULL;
        }
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *ps_python_set_var_uint32(PyObject *self, PyObject *args)
@@ -117,7 +117,7 @@ static PyObject *ps_python_set_var_uint32(PyObject *self, PyObject *args)
                PyErr_SetString(spoa_error, "No space left available");
                return NULL;
        }
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *ps_python_set_var_int64(PyObject *self, PyObject *args)
@@ -133,7 +133,7 @@ static PyObject *ps_python_set_var_int64(PyObject *self, PyObject *args)
                PyErr_SetString(spoa_error, "No space left available");
                return NULL;
        }
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *ps_python_set_var_uint64(PyObject *self, PyObject *args)
@@ -149,7 +149,7 @@ static PyObject *ps_python_set_var_uint64(PyObject *self, PyObject *args)
                PyErr_SetString(spoa_error, "No space left available");
                return NULL;
        }
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *ps_python_set_var_ipv4(PyObject *self, PyObject *args)
@@ -182,7 +182,7 @@ static PyObject *ps_python_set_var_ipv4(PyObject *self, PyObject *args)
        }
        /* Once we set the IP value in the worker, we don't need it anymore... */
        Py_XDECREF(value);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *ps_python_set_var_ipv6(PyObject *self, PyObject *args)
@@ -215,7 +215,7 @@ static PyObject *ps_python_set_var_ipv6(PyObject *self, PyObject *args)
        }
        /* Once we set the IP value in the worker, we don't need it anymore... */
        Py_XDECREF(value);
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *ps_python_set_var_str(PyObject *self, PyObject *args)
@@ -232,7 +232,7 @@ static PyObject *ps_python_set_var_str(PyObject *self, PyObject *args)
                PyErr_SetString(spoa_error, "No space left available");
                return NULL;
        }
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 static PyObject *ps_python_set_var_bin(PyObject *self, PyObject *args)
@@ -249,7 +249,7 @@ static PyObject *ps_python_set_var_bin(PyObject *self, PyObject *args)
                PyErr_SetString(spoa_error, "No space left available");
                return NULL;
        }
-       return Py_None;
+       Py_RETURN_NONE;
 }