python3-mallard-ducktype/mallard-ducktype-0.2-open-utf8.patch
David King 33798209d4 Add backported UTF-8 encoding patch
Fixes use of ducktype when the locale encoding is ascii, such as when
building an RPM.
2015-09-10 10:31:13 +01:00

39 lines
1.2 KiB
Diff

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