mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 22:46:15 +01:00
glib-mkenums: Use utf-8 for reading files
On Windows open() defaults to ANSI and on Python 2 it doesn't take an encoding. Use io.open() instead which provides the same interface on both Python versions. https://bugzilla.gnome.org/show_bug.cgi?id=785113
This commit is contained in:
parent
2ac8079b94
commit
c2dace6b8b
@ -14,6 +14,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import io
|
||||||
|
|
||||||
VERSION_STR = '''glib-mkenums version @VERSION@
|
VERSION_STR = '''glib-mkenums version @VERSION@
|
||||||
glib-genmarshal comes with ABSOLUTELY NO WARRANTY.
|
glib-genmarshal comes with ABSOLUTELY NO WARRANTY.
|
||||||
@ -147,7 +148,7 @@ def parse_entries(file, file_name):
|
|||||||
m = re.match(r'\#include\s*<([^>]*)>', line)
|
m = re.match(r'\#include\s*<([^>]*)>', line)
|
||||||
if m:
|
if m:
|
||||||
newfilename = os.path.join("..", m.group(1))
|
newfilename = os.path.join("..", m.group(1))
|
||||||
newfile = open(newfilename)
|
newfile = io.open(newfilename, encoding="utf-8")
|
||||||
|
|
||||||
if not parse_entries(newfile, newfilename):
|
if not parse_entries(newfile, newfilename):
|
||||||
return False
|
return False
|
||||||
@ -243,7 +244,7 @@ def read_template_file(file):
|
|||||||
}
|
}
|
||||||
in_ = 'junk'
|
in_ = 'junk'
|
||||||
|
|
||||||
ifile = open(file)
|
ifile = io.open(file, encoding="utf-8")
|
||||||
for line in ifile:
|
for line in ifile:
|
||||||
m = re.match(r'\/\*\*\*\s+(BEGIN|END)\s+([\w-]+)\s+\*\*\*\/', line)
|
m = re.match(r'\/\*\*\*\s+(BEGIN|END)\s+([\w-]+)\s+\*\*\*\/', line)
|
||||||
if m:
|
if m:
|
||||||
@ -397,7 +398,7 @@ def process_file(curfilename):
|
|||||||
firstenum = True
|
firstenum = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
curfile = open(curfilename)
|
curfile = io.open(curfilename, encoding="utf-8")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print_warning('No file "{}" found.'.format(curfilename))
|
print_warning('No file "{}" found.'.format(curfilename))
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user