[glib] glib-mkenums: fix encoding error when writing files
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] glib-mkenums: fix encoding error when writing files
- Date: Mon, 24 Jul 2017 09:27:15 +0000 (UTC)
commit b92e15c75df7ed517bc4b256c710cad5cfa43816
Author: Christoph Reiter <creiter src gnome org>
Date: Sat Jul 22 20:47:43 2017 +0200
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
gobject/glib-mkenums.in | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/gobject/glib-mkenums.in b/gobject/glib-mkenums.in
index 653a769..fccc000 100755
--- a/gobject/glib-mkenums.in
+++ b/gobject/glib-mkenums.in
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]