From 3e396b3782813d36d46195564cd0e111422bcaf5 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Tue, 22 Jun 2021 22:59:16 +0200 Subject: fix: Always explicitly set encoding for text files (fixes #8263) --- mesonbuild/compilers/compilers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index ff87819..52529f7 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -765,14 +765,14 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): if isinstance(code, str): srcname = os.path.join(tmpdirname, 'testfile.' + self.default_suffix) - with open(srcname, 'w') as ofile: + with open(srcname, 'w', encoding='utf-8') as ofile: ofile.write(code) # ccache would result in a cache miss no_ccache = True contents = code elif isinstance(code, mesonlib.File): srcname = code.fname - with open(code.fname) as f: + with open(code.fname, encoding='utf-8') as f: contents = f.read() # Construct the compiler command-line -- cgit v1.1