From 0d5123e69a3adbb401101ea486065f6d472318c2 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Wed, 10 Sep 2025 14:00:51 +0200 Subject: [PATCH] Trampoline Python unref again. In the past `Py_XDECREF()` was a macro. Preserve compat to ancient Python versions by having a trampoline which calls `Py_XDECREF()`. Fixes: #2043 Fixes: c0da36c4 ("Rage-cleanup.") Signed-off-by: Steffen Jaeckel (cherry picked from commit 3299dd8fc62dd317a9bdf83408d6d5e28b9ecfa0) --- src/plugins/python_plugins.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/python_plugins.c b/src/plugins/python_plugins.c index 13278750..3b50c961 100644 --- a/src/plugins/python_plugins.c +++ b/src/plugins/python_plugins.c @@ -86,10 +86,16 @@ python_get_version_number(void) return version_number; } +static void +_unref_module(PyObject* module) +{ + Py_XDECREF(module); +} + void python_env_init(void) { - loaded_modules = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)Py_XDECREF); + loaded_modules = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_unref_module); python_init_prof();