From 58e1a0c11e18eb7168310c55fc7ecaf86e3b6338 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Mon, 20 Jan 2025 06:07:20 +0100 Subject: [PATCH] Fix encoding of runfiles manifest and repository mapping files. See https://github.com/bazelbuild/bazel/issues/374#issuecomment-2594713891: > all output files produced by Bazel should use UTF-8 and \n line endings on > all platforms, including Windows. --- python/runfiles/runfiles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/runfiles/runfiles.py b/python/runfiles/runfiles.py index ea816c64fd..3943be5646 100644 --- a/python/runfiles/runfiles.py +++ b/python/runfiles/runfiles.py @@ -56,7 +56,7 @@ def RlocationChecked(self, path: str) -> Optional[str]: def _LoadRunfiles(path: str) -> Dict[str, str]: """Loads the runfiles manifest.""" result = {} - with open(path, "r") as f: + with open(path, "r", encoding="utf-8", newline="\n") as f: for line in f: line = line.rstrip("\n") if line.startswith(" "): @@ -367,7 +367,7 @@ def _ParseRepoMapping(repo_mapping_path: Optional[str]) -> Dict[Tuple[str, str], if not repo_mapping_path: return {} try: - with open(repo_mapping_path, "r") as f: + with open(repo_mapping_path, "r", encoding="utf-8", newline="\n") as f: content = f.read() except FileNotFoundError: return {}