From ff299eb36b7d5d89a3d2d1fdb5b489c9e7d05b29 Mon Sep 17 00:00:00 2001 From: jonathan MERCIER Date: Wed, 3 Apr 2019 20:42:15 +0200 Subject: Read file as utf8 on python3 --- mesonbuild/scripts/vcstagger.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/scripts/vcstagger.py b/mesonbuild/scripts/vcstagger.py index 62a45d9..16dd4d1 100644 --- a/mesonbuild/scripts/vcstagger.py +++ b/mesonbuild/scripts/vcstagger.py @@ -14,6 +14,7 @@ import sys, os, subprocess, re + def config_vcs_tag(infile, outfile, fallback, source_dir, replace_string, regex_selector, cmd): try: output = subprocess.check_output(cmd, cwd=source_dir) @@ -21,17 +22,18 @@ def config_vcs_tag(infile, outfile, fallback, source_dir, replace_string, regex_ except Exception: new_string = fallback - with open(infile) as f: + with open(infile, encoding='utf8') as f: new_data = f.read().replace(replace_string, new_string) if os.path.exists(outfile): - with open(outfile) as f: + with open(outfile, encoding='utf8') as f: needs_update = (f.read() != new_data) else: needs_update = True if needs_update: - with open(outfile, 'w') as f: + with open(outfile, 'w', encoding='utf8') as f: f.write(new_data) + def run(args): infile, outfile, fallback, source_dir, replace_string, regex_selector = args[0:6] command = args[6:] -- cgit v1.1