From 046931e64e9e081e82c341f6455d070716fb8cf2 Mon Sep 17 00:00:00 2001
From: Daniel Garcia Moreno <daniel.garcia@suse.com>
Date: Tue, 10 Mar 2026 20:30:20 +0100
Subject: [PATCH] python: Do not decref string after adding to the list

The python API PyList_SetItem function "steals" a reference to item, so
we don't need to call Py_DECREF here.

https://docs.python.org/3.13/c-api/list.html#c.PyList_SetItem

Fix https://gitlab.gnome.org/GNOME/libxml2/-/issues/1076
---
 python/libxml.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/python/libxml.c b/python/libxml.c
index c35ebff4f..c5e93cef8 100644
--- a/python/libxml.c
+++ b/python/libxml.c
@@ -1215,7 +1215,6 @@ XML_IGNORE_DEPRECATION_WARNINGS
         for (node = tree; node != NULL; node = node->next) {
             newName = PY_IMPORT_STRING((char *) node->name);
             PyList_SetItem(nameList, count, newName);
-	    Py_DECREF(newName);
             count++;
         }
         result = PyObject_CallMethod(handler, "attributeDecl",
-- 
GitLab

