Projet

Général

Profil

0001-extract_types.py-force-io-to-use-UTF-8-encoding-fixe.patch

Benjamin Dauvergne, 15 octobre 2018 11:27

Télécharger (2,68 ko)

Voir les différences:

Subject: [PATCH] extract_types.py: force io to use UTF-8 encoding (fixes
 #27332)

 lasso/extract_types.py | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
lasso/extract_types.py
1 1
#! /usr/bin/env python
2 2

  
3
import io
3 4
import glob
4 5
import re
5 6
import sys
6
from six.moves import cStringIO as StringIO
7 7
import six
8 8

  
9 9
enable_wsf = 0
......
24 24
if enable_wsf:
25 25
    wsf = []
26 26

  
27
fd = StringIO()
27
fd = io.StringIO()
28 28

  
29
six.print_("/* This file has been autogenerated; changes will be lost */", file=fd)
30
six.print_("", file=fd)
31
six.print_("typedef GType (*type_function) ();", file=fd)
32
six.print_("", file=fd)
29
six.print_(u"/* This file has been autogenerated; changes will be lost */", file=fd)
30
six.print_(u"", file=fd)
31
six.print_(u"typedef GType (*type_function) ();", file=fd)
32
six.print_(u"", file=fd)
33 33

  
34 34
header_files = []
35 35
for header_file in glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*/*/*.h' % srcdir):
......
37 37
        continue
38 38
    header_files.append(header_file)
39 39
    try:
40
        type = re.findall('lasso_.*get_type', open(header_file).read())[0]
40
        type = re.findall('lasso_.*get_type', io.open(header_file, encoding='utf-8').read())[0]
41 41
    except IndexError:
42 42
        continue
43 43
    for t in wsf:
......
46 46
    else:
47 47
        six.print_("extern GType %s();" % type, file=fd)
48 48

  
49
six.print_("", file=fd)
50
six.print_("type_function functions[] = {", file=fd)
49
six.print_(u"", file=fd)
50
six.print_(u"type_function functions[] = {", file=fd)
51 51
for header_file in header_files:
52 52
    try:
53
        type = re.findall('lasso_.*get_type', open(header_file).read())[0]
53
        type = re.findall('lasso_.*get_type', io.open(header_file, encoding='utf-8').read())[0]
54 54
    except IndexError:
55 55
        continue
56 56
    for t in wsf:
57 57
        if type.startswith(t):
58 58
            break
59 59
    else:
60
        six.print_("\t%s," % type, file=fd)
61
six.print_("\tNULL", file=fd)
62
six.print_("};", file=fd)
60
        six.print_(u"\t%s," % type, file=fd)
61
six.print_(u"\tNULL", file=fd)
62
six.print_(u"};", file=fd)
63 63

  
64
open('types.c', 'w').write(fd.getvalue())
64
io.open('types.c', 'w', encoding='utf-8').write(fd.getvalue())
65
-