From a03227d3e2653753e9414ab8b217a0e2542e9ea7 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 29 Aug 2014 15:22:24 +0200 Subject: [PATCH] Fix reference count issue in the set_log_handler() method of the Python module + Allow setting its value to None. --- tools/python/apixml2python/handwritten_definitions.mustache | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/python/apixml2python/handwritten_definitions.mustache b/tools/python/apixml2python/handwritten_definitions.mustache index 4aab9c78d..a4b3e579f 100644 --- a/tools/python/apixml2python/handwritten_definitions.mustache +++ b/tools/python/apixml2python/handwritten_definitions.mustache @@ -104,12 +104,11 @@ static PyObject * pylinphone_module_method_set_log_handler(PyObject *self, PyObj if (!PyArg_ParseTuple(args, "O", &callback)) { return NULL; } - if (!PyCallable_Check(callback)) { - PyErr_SetString(PyExc_TypeError, "The argument must be a callable"); + if (!PyCallable_Check(callback) && (callback != Py_None)) { + PyErr_SetString(PyExc_TypeError, "The argument must be a callable or None"); return NULL; } if (linphone_module != NULL) { - Py_INCREF(callback); PyObject_SetAttrString(linphone_module, "__log_handler", callback); Py_DECREF(linphone_module); }