mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
glib-mkenums: fix encoding error when writing files
Instead of using NamedTemporaryFile, which doesn't take an encoding in Python 2 use mkstemp() to create a file and open it with io.open(), with a proper encoding set. https://bugzilla.gnome.org/show_bug.cgi?id=785113
This commit is contained in:
parent
039c40e6ec
commit
b92e15c75d
@ -366,7 +366,9 @@ if output is not None:
|
||||
out_suffix = '_' + os.path.splitext(out_fn)[1]
|
||||
if out_dir == '':
|
||||
out_dir = '.'
|
||||
tmpfile = tempfile.NamedTemporaryFile(dir=out_dir, delete=False)
|
||||
fd, filename = tempfile.mkstemp(dir=out_dir)
|
||||
os.close(fd)
|
||||
tmpfile = io.open(filename, "w", encoding="utf-8")
|
||||
output_stream = tmpfile
|
||||
else:
|
||||
tmpfile = None
|
||||
|
Loading…
Reference in New Issue
Block a user