Module: kamailio
Branch: master
Commit: be39bc8fd67c38f6a2b9d07047bb990a1ffacf77
URL: 
https://github.com/kamailio/kamailio/commit/be39bc8fd67c38f6a2b9d07047bb990a1ffacf77

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2023-09-21T14:56:25+02:00

app_python3s: use PyErr_Clear() in case of errors

---

Modified: src/modules/app_python3s/apy3s_kemi.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/be39bc8fd67c38f6a2b9d07047bb990a1ffacf77.diff
Patch: 
https://github.com/kamailio/kamailio/commit/be39bc8fd67c38f6a2b9d07047bb990a1ffacf77.patch

---

diff --git a/src/modules/app_python3s/apy3s_kemi.c 
b/src/modules/app_python3s/apy3s_kemi.c
index 9130a84f9fa..b5041bba4ef 100644
--- a/src/modules/app_python3s/apy3s_kemi.c
+++ b/src/modules/app_python3s/apy3s_kemi.c
@@ -76,6 +76,9 @@ int apy3s_exec_func(sip_msg_t *_msg, char *fname, char 
*fparam, int emode)
                return -1;
        }
 
+       /* clear error state */
+       PyErr_Clear();
+
        if(lock_try(_sr_python_reload_lock) == 0) {
                if(_sr_python_reload_version
                                && *_sr_python_reload_version != 
_sr_python_local_version) {
@@ -98,11 +101,13 @@ int apy3s_exec_func(sip_msg_t *_msg, char *fname, char 
*fparam, int emode)
 
        if(pFunc == NULL || !PyCallable_Check(pFunc)) {
                if(emode == 1) {
-                       LM_ERR("%s not found or is not callable\n", fname);
+                       LM_ERR("%s not found or is not callable (%p)\n", fname, 
pFunc);
                } else {
-                       LM_DBG("%s not found or is not callable\n", fname);
+                       LM_DBG("%s not found or is not callable (%p)\n", fname, 
pFunc);
+               }
+               if(pFunc) {
+                       Py_XDECREF(pFunc);
                }
-               Py_XDECREF(pFunc);
                _sr_apy_env.msg = bmsg;
                if(emode == 1) {
                        goto error;
@@ -157,6 +162,8 @@ int apy3s_exec_func(sip_msg_t *_msg, char *fname, char 
*fparam, int emode)
        if(locked) {
                lock_release(_sr_python_reload_lock);
        }
+       /* clear error state */
+       PyErr_Clear();
        return rval;
 }
 

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to