diff options
author | Đoàn Trần Công Danh <congdanhqx@gmail.com> | 2022-09-22 21:53:13 +0700 |
---|---|---|
committer | Đoàn Trần Công Danh <congdanhqx@gmail.com> | 2022-09-24 12:49:12 +0700 |
commit | 5a72fefe892f86423dde2c338879ea27a6489f03 (patch) | |
tree | 64e3c4af511adc89943618c345b3e453ee508c44 /src/plugins | |
parent | fcc20628d5a01c3d1c7a26fca48d79631eaac93d (diff) | |
download | profani-tty-5a72fefe892f86423dde2c338879ea27a6489f03.tar.gz |
plugin: python: fix build for Python 3.11
From Python 3.11, PyFrameObject has been changed into opaque struct. We need to access those fields via API. Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/python_api.c | 8 |
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]); |