]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use accessor function for PyFrameObject members on python >= 3.10
authorNick Porter <nick@portercomputing.co.uk>
Fri, 13 Jan 2023 18:05:38 +0000 (18:05 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 16 Jan 2023 08:48:08 +0000 (08:48 +0000)
src/modules/rlm_python/rlm_python.c

index 9601f37331a9923e6b542b49adb20f7bec1a8e5d..489fec187aa39ac493f36d5eee67dd21b621e2e9 100644 (file)
@@ -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++;