aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2022-09-25 22:34:25 +0200
committerGitHub <noreply@github.com>2022-09-25 22:34:25 +0200
commit7ffe55e980a7d33f1129331bb5dc34c6455b55a4 (patch)
tree8038003e12e16d9c728eb909df83a061b9ad2fe0 /src/plugins
parent338b9587bdbfcda16daf2a016de0c5cf32858239 (diff)
parent5a72fefe892f86423dde2c338879ea27a6489f03 (diff)
downloadprofani-tty-7ffe55e980a7d33f1129331bb5dc34c6455b55a4.tar.gz
Merge pull request #1756 from sgn/python-3.11
plugin: python: fix build for Python 3.11
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/python_api.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c
index 0b91cf70..091b3b4a 100644
--- a/src/plugins/python_api.c
+++ b/src/plugins/python_api.c
@@ -1619,8 +1619,16 @@ static char*
_python_plugin_name(void)
{
PyThreadState* ts = PyThreadState_Get();
+#if PY_VERSION_HEX >= 0x030B0000
+ PyFrameObject* frame = PyThreadState_GetFrame(ts);
+ PyCodeObject* code = PyFrame_GetCode(frame);
+ char* filename = python_str_or_unicode_to_string(code->co_filename);
+ Py_DECREF(code);
+ Py_DECREF(frame);
+#else
PyFrameObject* frame = ts->frame;
char* filename = python_str_or_unicode_to_string(frame->f_code->co_filename);
+#endif
gchar** split = g_strsplit(filename, "/", 0);
free(filename);
char* plugin_name = strdup(split[g_strv_length(split) - 1]);