Skip to content

Commit

Permalink
improve exception handling. Helps with #5242
Browse files Browse the repository at this point in the history
so that no python exceptions remain after the do_python_single call.
Otherwise the next request will immediately fail.

Patch from #5242, but separated out to keep commit history
a little clearer.
  • Loading branch information
alandekok committed Jan 5, 2024
1 parent a523315 commit f928118
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/modules/rlm_python3/rlm_python3.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ static int mod_populate_vptuple(PyObject *pPair, VALUE_PAIR *vp)
ERROR("%s:%d, vp->da->name: %s", __func__, __LINE__, vp->da->name);
if (PyErr_Occurred()) {
python_error_log();
PyErr_Clear();
}

return -1;
Expand Down Expand Up @@ -567,6 +568,7 @@ static rlm_rcode_t do_python_single(REQUEST *request, PyObject *pFunc, char cons
ERROR("%s:%d, %s - pRet is NULL", __func__, __LINE__, funcname);
if (PyErr_Occurred()) {
python_error_log();
PyErr_Clear();
}
ret = RLM_MODULE_FAIL;
goto finish;
Expand Down Expand Up @@ -674,6 +676,13 @@ static rlm_rcode_t do_python_single(REQUEST *request, PyObject *pFunc, char cons
if (ret == RLM_MODULE_FAIL) {
ERROR("%s:%d, %s - RLM_MODULE_FAIL", __func__, __LINE__, funcname);
}

if (PyErr_Occurred()) {
ERROR("Unhandled Python exception (see below); clearing.");
python_error_log();
PyErr_Clear();
}

return ret;
}

Expand Down

0 comments on commit f928118

Please sign in to comment.