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/backend/ninjabackend.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'mesonbuild/backend/ninjabackend.py') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 192cef3..597789b 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -20,6 +20,7 @@ import subprocess from collections import OrderedDict from enum import Enum, unique import itertools +from textwrap import dedent from pathlib import PurePath, Path from functools import lru_cache @@ -462,10 +463,11 @@ class NinjaBackend(backends.Backend): return open(tempfilename, 'a', encoding='utf-8') filename = os.path.join(self.environment.get_scratch_dir(), 'incdetect.c') - with open(filename, 'w') as f: - f.write('''#include -int dummy; -''') + with open(filename, 'w', encoding='utf-8') as f: + f.write(dedent('''\ + #include + int dummy; + ''')) # The output of cl dependency information is language # and locale dependent. Any attempt at converting it to @@ -1215,7 +1217,7 @@ int dummy; manifest_path = os.path.join(self.get_target_private_dir(target), 'META-INF', 'MANIFEST.MF') manifest_fullpath = os.path.join(self.environment.get_build_dir(), manifest_path) os.makedirs(os.path.dirname(manifest_fullpath), exist_ok=True) - with open(manifest_fullpath, 'w') as manifest: + with open(manifest_fullpath, 'w', encoding='utf-8') as manifest: if any(target.link_targets): manifest.write('Class-Path: ') cp_paths = [os.path.join(self.get_target_dir(l), l.get_filename()) for l in target.link_targets] -- cgit v1.1