From d59b3827d2bb62c1ed4db8030ed9e8e753b7f52d Mon Sep 17 00:00:00 2001 From: Simon Feltman Date: Mon, 28 Apr 2014 16:21:35 -0700 Subject: giscanner: Use unicode literals in all Python files Add unicode_literals future import which turns any string literal into a unicode string. Return unicode strings from the Python C extension module. Force writing of annotations (g-ir-annotation-tool) to output utf8 encoded data to stdout. This is an initial pass at following the "unicode sandwich" model of programming (http://nedbatchelder.com/text/unipain.html) needed for supporting Python 3. https://bugzilla.gnome.org/show_bug.cgi?id=679438 --- misc/update-glib-annotations.py | 6 +++++- misc/verbump.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'misc') diff --git a/misc/update-glib-annotations.py b/misc/update-glib-annotations.py index 200a02a7..6d7c7d65 100755 --- a/misc/update-glib-annotations.py +++ b/misc/update-glib-annotations.py @@ -6,6 +6,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from __future__ import unicode_literals import os import sys @@ -100,7 +101,10 @@ if __name__ == '__main__': if os.path.isfile(srcname): os.unlink(srcname) - srcfile = open(tmpname, 'w') + # Extract annotations into a file opened in binary mode. + # Since g-ir-scanner-tool outputs utf-8 encoded data, we simply pass + # that directly into this file via. the underlying subprocess call. + srcfile = open(tmpname, 'wb') extract_annotations(module, srcdir, builddir, srcfile) srcfile.close() os.rename(tmpname, srcname) diff --git a/misc/verbump.py b/misc/verbump.py index 679ef065..b8a8f4fd 100644 --- a/misc/verbump.py +++ b/misc/verbump.py @@ -6,6 +6,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from __future__ import unicode_literals import re import os -- cgit v1.2.1