3379820
From ec2b427c8b9555b9fb4fa045c6cdd7a5878d9583 Mon Sep 17 00:00:00 2001
3379820
From: David King <dking@redhat.com>
3379820
Date: Wed, 9 Sep 2015 11:32:08 +0100
3379820
Subject: [PATCH] Open files as UTF-8
3379820
3379820
Do not rely on the platform-preferred encoding when opening files, and
3379820
instead force UTF-8 encoding.
3379820
3379820
Fixes #11
3379820
---
3379820
 mallard/ducktype/parser.py | 4 ++--
3379820
 1 file changed, 2 insertions(+), 2 deletions(-)
3379820
3379820
diff --git a/mallard/ducktype/parser.py b/mallard/ducktype/parser.py
3379820
index 35ea594..da73f54 100644
3379820
--- a/mallard/ducktype/parser.py
3379820
+++ b/mallard/ducktype/parser.py
3379820
@@ -169,7 +169,7 @@ class Node:
3379820
             fd = sys.stdout
3379820
         elif isinstance(outfile, str):
3379820
             close = True
3379820
-            fd = open(outfile, 'w')
3379820
+            fd = open(outfile, 'w', encoding='utf-8')
3379820
         else:
3379820
             fd = outfile
3379820
         self._write_xml(fd)
3379820
@@ -651,7 +651,7 @@ class DuckParser:
3379820
         self._defaultid = os.path.basename(filename)
3379820
         if self._defaultid.endswith('.duck'):
3379820
             self._defaultid = self._defaultid[:-5]
3379820
-        fd = open(filename)
3379820
+        fd = open(filename, encoding='utf-8')
3379820
         for line in fd:
3379820
             self.parse_line(line)
3379820
         fd.close()
3379820
-- 
3379820
2.5.1
3379820