Skip to content

Commit

Permalink
Fix encoding of runfiles manifest and repository mapping files.
Browse files Browse the repository at this point in the history
See bazelbuild/bazel#374 (comment):

> all output files produced by Bazel should use UTF-8 and \n line endings on
> all platforms, including Windows.
  • Loading branch information
phst committed Jan 20, 2025
1 parent a7b7126 commit 58e1a0c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/runfiles/runfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(" "):
Expand Down Expand Up @@ -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 {}
Expand Down

0 comments on commit 58e1a0c

Please sign in to comment.