Fix reference count issue in the set_log_handler() method of the Python module + Allow setting its value to None.

This commit is contained in:
Ghislain MARY 2014-08-29 15:22:24 +02:00
parent 1caa2d8de3
commit a03227d3e2

View file

@ -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);
}