$OpenBSD: patch-tools_c-constants-gen_py,v 1.1 2021/02/15 08:44:05 sthen Exp $

From ffc23c3b3d49d265997b6bb5d55d9463080c1cc8 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@freedesktop.org>
Date: Mon, 10 Feb 2020 15:20:38 +0100
Subject: [PATCH] tools: Fix the build with Python 3

Index: tools/c-constants-gen.py
--- tools/c-constants-gen.py.orig
+++ tools/c-constants-gen.py
@@ -3,7 +3,7 @@
 from sys import argv, stdout, stderr
 import xml.dom.minidom
 
-from libtpcodegen import file_set_contents
+from libtpcodegen import file_set_contents, u
 from libglibcodegen import NS_TP, get_docstring, \
         get_descendant_text, get_by_path
 
@@ -12,7 +12,7 @@ class Generator(object):
         self.prefix = prefix + '_'
         self.spec = get_by_path(dom, "spec")[0]
 
-	self.output_base = output_base
+        self.output_base = output_base
         self.__header = []
         self.__docs = []
 
@@ -21,14 +21,14 @@ class Generator(object):
         self.do_body()
         self.do_footer()
 
-        file_set_contents(self.output_base + '.h', ''.join(self.__header))
-        file_set_contents(self.output_base + '-gtk-doc.h', ''.join(self.__docs))
+        file_set_contents(self.output_base + '.h', u('').join(self.__header).encode('utf-8'))
+        file_set_contents(self.output_base + '-gtk-doc.h', u('').join(self.__docs).encode('utf-8'))
 
     def write(self, code):
-        self.__header.append(code.encode('utf-8'))
+        self.__header.append(code)
 
     def d(self, code):
-        self.__docs.append(code.encode('utf-8'))
+        self.__docs.append(code)
 
     # Header
     def do_header(self):
