logging_backend/python: Do not call 'GATTLIB_LOG(GATTLIB_ERROR, ...)' on error to avoid recursion

create-package
Olivier Martin 2024-03-26 15:53:36 +01:00
parent 6e6436ceb3
commit 5d9a36f1d1
1 changed files with 4 additions and 3 deletions

View File

@ -42,13 +42,14 @@ void gattlib_log(int level, const char *format, ...) {
#else
result = PyEval_CallObject(m_logging_func, arglist);
#endif
Py_DECREF(arglist);
if (result == NULL) {
GATTLIB_LOG(GATTLIB_ERROR, "Python notification handler has raised an exception.");
// We do not call GATTLIB_LOG(GATTLIB_ERROR, "") in case of error to avoid recursion
fprintf(stderr, "Failed to call Python logging function for this logging: %s\n", format);
PyErr_Print();
}
Py_DECREF(arglist);
PyGILState_Release(d_gstate);
}