summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2018-10-15 09:27:09 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2018-10-15 09:27:09 (GMT)
commit580aca65b12255d8672eae1e373396bf54460960 (patch)
tree2389821c09396bdc30ab88b7b742802e460b6818
parent14febd3c5f693c928b5f99eb83bc9a2385f4d176 (diff)
downloadlasso-580aca65b12255d8672eae1e373396bf54460960.zip
lasso-580aca65b12255d8672eae1e373396bf54460960.tar.gz
lasso-580aca65b12255d8672eae1e373396bf54460960.tar.bz2
extract_types.py: force io to use UTF-8 encoding (fixes #27332)
-rw-r--r--lasso/extract_types.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/lasso/extract_types.py b/lasso/extract_types.py
index 2bacbd5..1359caf 100644
--- a/lasso/extract_types.py
+++ b/lasso/extract_types.py
@@ -1,9 +1,9 @@
#! /usr/bin/env python
+import io
import glob
import re
import sys
-from six.moves import cStringIO as StringIO
import six
enable_wsf = 0
@@ -24,12 +24,12 @@ wsf = ['lasso_disco_', 'lasso_dst_', 'lasso_is_', 'lasso_profile_service_',
if enable_wsf:
wsf = []
-fd = StringIO()
+fd = io.StringIO()
-six.print_("/* This file has been autogenerated; changes will be lost */", file=fd)
-six.print_("", file=fd)
-six.print_("typedef GType (*type_function) ();", file=fd)
-six.print_("", file=fd)
+six.print_(u"/* This file has been autogenerated; changes will be lost */", file=fd)
+six.print_(u"", file=fd)
+six.print_(u"typedef GType (*type_function) ();", file=fd)
+six.print_(u"", file=fd)
header_files = []
for header_file in glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*/*/*.h' % srcdir):
@@ -37,7 +37,7 @@ for header_file in glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*/*/*.h' % src
continue
header_files.append(header_file)
try:
- type = re.findall('lasso_.*get_type', open(header_file).read())[0]
+ type = re.findall('lasso_.*get_type', io.open(header_file, encoding='utf-8').read())[0]
except IndexError:
continue
for t in wsf:
@@ -46,19 +46,19 @@ for header_file in glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*/*/*.h' % src
else:
six.print_("extern GType %s();" % type, file=fd)
-six.print_("", file=fd)
-six.print_("type_function functions[] = {", file=fd)
+six.print_(u"", file=fd)
+six.print_(u"type_function functions[] = {", file=fd)
for header_file in header_files:
try:
- type = re.findall('lasso_.*get_type', open(header_file).read())[0]
+ type = re.findall('lasso_.*get_type', io.open(header_file, encoding='utf-8').read())[0]
except IndexError:
continue
for t in wsf:
if type.startswith(t):
break
else:
- six.print_("\t%s," % type, file=fd)
-six.print_("\tNULL", file=fd)
-six.print_("};", file=fd)
+ six.print_(u"\t%s," % type, file=fd)
+six.print_(u"\tNULL", file=fd)
+six.print_(u"};", file=fd)
-open('types.c', 'w').write(fd.getvalue())
+io.open('types.c', 'w', encoding='utf-8').write(fd.getvalue())