From: Petr Viktorin <encukou@gmail.com>
Date: Tue, 3 Sep 2019 13:54:49 +0200
Subject: Make gtk-builder-convert compatible with Python 3

- Convert tabs to spaces
- Use print as a function, even on Python 2
- Output a binary file, or decode for stdout

Origin: upstream, 2.24.33, commit:3ff8f70b9686205f0618d7a479fd42a457b90165
---
 gtk/gtk-builder-convert | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/gtk/gtk-builder-convert b/gtk/gtk-builder-convert
index ea737de..41f7a8c 100755
--- a/gtk/gtk-builder-convert
+++ b/gtk/gtk-builder-convert
@@ -36,6 +36,7 @@ Examples:
 
 Report bugs to http://bugzilla.gnome.org/."""
 
+from __future__ import print_function
 import getopt
 import os
 import sys
@@ -259,7 +260,7 @@ class GtkBuilderConverter(object):
         for node in objects:
             self._convert(node.getAttribute("class"), node)
             if self._get_object(node.getAttribute('id')) is not None:
-		print "WARNING: duplicate id \"" + node.getAttribute('id') + "\""
+                print("WARNING: duplicate id \"" + node.getAttribute('id') + "\"")
             self.objects[node.getAttribute('id')] = node
 
         # Convert Gazpachos UI tag
@@ -277,8 +278,7 @@ class GtkBuilderConverter(object):
         #                   reverse=True):
         # when we can depend on python 2.4 or higher
         root_objects = self.root_objects[:]
-        root_objects.sort(lambda a, b: cmp(b.getAttribute('id'),
-                                           a.getAttribute('id')))
+        root_objects.sort(key=lambda a: a.getAttribute('id'), reverse=True)
         for obj in root_objects:
             self._interface.childNodes.insert(0, obj)
 
@@ -461,8 +461,8 @@ class GtkBuilderConverter(object):
             if signal_name in ['activate', 'toggled']:
                 action.appendChild(signal)
             else:
-                print 'Unhandled signal %s::%s' % (node.getAttribute('class'),
-                                                   signal_name)
+                print('Unhandled signal %s::%s' % (node.getAttribute('class'),
+                                                   signal_name))
 
         if not uimgr.childNodes:
             child = self._dom.createElement('child')
@@ -481,8 +481,8 @@ class GtkBuilderConverter(object):
         for accelerator in get_accelerator_nodes(node):
             signal_name = accelerator.getAttribute('signal')
             if signal_name != 'activate':
-                print 'Unhandled accelerator signal for %s::%s' % (
-                    node.getAttribute('class'), signal_name)
+                print('Unhandled accelerator signal for %s::%s' % (
+                    node.getAttribute('class'), signal_name))
                 continue
             accelerator.removeAttribute('signal')
             child.appendChild(accelerator)
@@ -747,7 +747,7 @@ def _indent(output):
     return s.stdout.read()
 
 def usage():
-    print __doc__
+    print(__doc__)
 
 def main(args):
     try:
@@ -788,10 +788,13 @@ def main(args):
 
     xml = _indent(conv.to_xml())
     if output_filename == "-":
-        print xml
+        if isinstance(xml, str):
+            print(xml)
+        else:
+            print(xml.decode(sys.stdout.encoding))
     else:
-        open(output_filename, 'w').write(xml)
-        print "Wrote", output_filename
+        open(output_filename, 'wb').write(xml)
+        print("Wrote", output_filename)
 
     return 0
 
