From: Nick Porter Date: Fri, 13 Jan 2023 18:05:38 +0000 (+0000) Subject: Use accessor function for PyFrameObject members on python >= 3.10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fac2aff7b099af6e678290e0ddd186c747bbd3d9;p=thirdparty%2Ffreeradius-server.git Use accessor function for PyFrameObject members on python >= 3.10 --- diff --git a/src/modules/rlm_python/rlm_python.c b/src/modules/rlm_python/rlm_python.c index 9601f37331a..489fec187aa 100644 --- a/src/modules/rlm_python/rlm_python.c +++ b/src/modules/rlm_python/rlm_python.c @@ -220,13 +220,27 @@ static void python_error_log(module_ctx_t const *mctx, request_t *request) while (ptb != NULL) { PyFrameObject *cur_frame = ptb->tb_frame; +#if PY_VERSION_HEX >= 0x030A0000 + PyCodeObject *code = PyFrame_GetCode(cur_frame); +#endif ROPTIONAL(RERROR, ERROR, "[%ld] %s:%d at %s()", fnum, +#if PY_VERSION_HEX >= 0x030A0000 + PyUnicode_AsUTF8(code->co_filename), +#else PyUnicode_AsUTF8(cur_frame->f_code->co_filename), +#endif PyFrame_GetLineNumber(cur_frame), +#if PY_VERSION_HEX >= 0x30A0000 + PyUnicode_AsUTF8(code->co_name) +#else PyUnicode_AsUTF8(cur_frame->f_code->co_name) +#endif ); +#if PY_VERSION_HEX >= 0x030A0000 + Py_XDECREF(code); +#endif ptb = ptb->tb_next; fnum++;