From 8b619420f994f5c77eb6540262277a0e668d7899 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 20 Mar 2016 21:21:23 +0200 Subject: [PATCH] Open Meson and option files explicitly as utf-8. Closes #467. --- mesonbuild/interpreter.py | 4 ++-- mesonbuild/optinterpreter.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index f4b695861..04bfa079c 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -925,7 +925,7 @@ class Interpreter(): mesonfile = os.path.join(self.source_root, self.subdir, environment.build_filename) if not os.path.isfile(mesonfile): raise InvalidArguments('Missing Meson file in %s' % mesonfile) - code = open(mesonfile).read() + code = open(mesonfile, encoding='utf8').read() if len(code.strip()) == 0: raise InvalidCode('Builder file is empty.') assert(isinstance(code, str)) @@ -1783,7 +1783,7 @@ class Interpreter(): absname = os.path.join(self.environment.get_source_dir(), buildfilename) if not os.path.isfile(absname): raise InterpreterException('Nonexistant build def file %s.' % buildfilename) - code = open(absname).read() + code = open(absname, encoding='utf8').read() assert(isinstance(code, str)) try: codeblock = mparser.Parser(code).parse() diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py index f0c93ae01..30a26ab77 100644 --- a/mesonbuild/optinterpreter.py +++ b/mesonbuild/optinterpreter.py @@ -73,7 +73,7 @@ class OptionInterpreter: def process(self, option_file): try: - ast = mparser.Parser(open(option_file, 'r').read()).parse() + ast = mparser.Parser(open(option_file, 'r', encoding='utf8').read()).parse() except coredata.MesonException as me: me.file = option_file raise me