From cf5da892330bbbfcfada26f62b4c616010fb5c20 Mon Sep 17 00:00:00 2001 From: Daniel Garcia Moreno Date: Mon, 30 Mar 2026 13:02:38 +0200 Subject: [PATCH] python: Fix generator.py with python3 unicode --- python/generator.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/generator.py b/python/generator.py index 64330526d..e06b1d4b4 100755 --- a/python/generator.py +++ b/python/generator.py @@ -415,14 +415,19 @@ for file in os.listdir(xmlDocDir): docs = extractDocs(func.find('detaileddescription')) + # python 2.7 compat, https://gitlab.gnome.org/GNOME/libxml2/-/issues/1092 + encoding = 'unicode' + if sys.version_info[0] == 2: + encoding = 'utf-8' + rtype = etree.tostring(func.find('type'), - method='text', encoding='utf-8').rstrip() + method='text', encoding=encoding).rstrip() valid = True args = [] for arg in func.findall('param'): atype = etree.tostring(arg.find('type'), - method='text', encoding='utf-8').rstrip() + method='text', encoding=encoding).rstrip() if atype == 'void': continue