From b6ffad41cae204d1cb71de537d0ae71242429d91 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Fri, 4 Feb 2022 15:53:45 +0100 Subject: [PATCH] gst-python: gstmodule.c: fix build with 3.11 https://docs.python.org/fr/3.10/whatsnew/3.10.html Part-of: --- .../gst-python/gi/overrides/gstmodule.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-python/gi/overrides/gstmodule.c b/subprojects/gst-python/gi/overrides/gstmodule.c index 2308eb7dcd..dc8364a344 100644 --- a/subprojects/gst-python/gi/overrides/gstmodule.c +++ b/subprojects/gst-python/gi/overrides/gstmodule.c @@ -685,22 +685,37 @@ pygst_debug_log (PyObject * pyobject, PyObject * string, GstDebugLevel level, frame = PyEval_GetFrame (); { +#if PY_VERSION_HEX < 0x030a0000 + PyCodeObject *code = frame->f_code; +#else + PyCodeObject *code = PyFrame_GetCode (frame); +#endif PyObject *utf8; const gchar *utf8_str; - utf8 = PyUnicode_AsUTF8String (frame->f_code->co_name); + utf8 = PyUnicode_AsUTF8String (code->co_name); utf8_str = PyBytes_AS_STRING (utf8); function = g_strdup (utf8_str); Py_DECREF (utf8); - utf8 = PyUnicode_AsUTF8String (frame->f_code->co_filename); + utf8 = PyUnicode_AsUTF8String (code->co_filename); utf8_str = PyBytes_AS_STRING (utf8); filename = g_strdup (utf8_str); Py_DECREF (utf8); +#if PY_VERSION_HEX < 0x030a0000 + lineno = PyCode_Addr2Line (frame->f_code, frame->f_lasti); +#else + lineno = PyFrame_GetLineNumber (frame); +#endif + +#if PY_VERSION_HEX >= 0x030a0000 + Py_DECREF (code); +#endif } - lineno = PyCode_Addr2Line (frame->f_code, frame->f_lasti); + + /* gst_debug_log : category, level, file, function, line, object, format, va_list */ if (isgstobject) object = G_OBJECT (pygobject_get (pyobject));