3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/libraries/science/math/fenics/unicode.patch
2017-08-15 16:19:45 +02:00

68 lines
2.4 KiB
Diff

From 0cc9e68de1181d950d4185bf3a87b69a87e4358f Mon Sep 17 00:00:00 2001
From: "James D. Trotter" <james@simula.no>
Date: Mon, 14 Aug 2017 16:43:53 +0200
Subject: [PATCH] Use a UTF-8 encoding to avoid errors with decoding non-ascii
characters
---
cmake/scripts/generate-swig-interface.py | 6 +++---
utils/pylit/pylit.py | 10 +++++++---
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/cmake/scripts/generate-swig-interface.py b/cmake/scripts/generate-swig-interface.py
index 843a49229..7b85453d0 100644
--- a/cmake/scripts/generate-swig-interface.py
+++ b/cmake/scripts/generate-swig-interface.py
@@ -212,10 +212,10 @@ def extract_swig_modules_dependencies(module_to_submodules, submodule_info):
continue
# Read code
- with open(header_file) as f:
- code = f.read()
-
try:
+ with open(header_file, encoding='utf-8') as f:
+ code = f.read()
+
# Extract type info
used_types, declared_types = parse_and_extract_type_info(code)
except Exception as e:
diff --git a/utils/pylit/pylit.py b/utils/pylit/pylit.py
index bcd8ec5e0..8c2964fbd 100755
--- a/utils/pylit/pylit.py
+++ b/utils/pylit/pylit.py
@@ -1496,7 +1496,7 @@ def open_streams(infile = '-', outfile = '-', overwrite='update', **keyw):
if infile == '-':
in_stream = sys.stdin
else:
- in_stream = open(infile, 'r')
+ in_stream = open(infile, 'r', encoding='utf-8')
if outfile == '-':
out_stream = sys.stdout
@@ -1505,7 +1505,7 @@ def open_streams(infile = '-', outfile = '-', overwrite='update', **keyw):
elif overwrite == 'update' and is_newer(outfile, infile):
raise IOError((1, "Output file is newer than input file!", outfile))
else:
- out_stream = open(outfile, 'w')
+ out_stream = open(outfile, 'w', encoding='utf-8')
return (in_stream, out_stream)
# is_newer
@@ -1731,7 +1731,11 @@ def main(args=sys.argv[1:], **defaults):
# Convert and write to out_stream::
- out_stream.write(str(converter))
+ try:
+ out_stream.write(str(converter))
+ except Exception as e:
+ print("Failed to write extract to", out_stream.name)
+ raise
if out_stream is not sys.stdout:
print("extract written to", out_stream.name)
--
2.14.0