Skip to content

Commit 3e336e6

Browse files
committed
Fix encoding of runfiles manifest and repository mapping files.
See bazelbuild/bazel#374 (comment): > all output files produced by Bazel should use UTF-8 and \n line endings on > all platforms, including Windows.
1 parent f219112 commit 3e336e6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Unreleased changes template.
5959
* (gazelle) Providing multiple input requirements files to `gazelle_python_manifest` now works correctly.
6060
* (pypi) Handle trailing slashes in pip index URLs in environment variables,
6161
fixes [#2554](https://github.com/bazelbuild/rules_python/issues/2554).
62+
* (runfiles) Runfile manifest and repository mapping files are now interpreted
63+
as UTF-8 on all platforms.
6264

6365
{#v0-0-0-added}
6466
### Added

python/runfiles/runfiles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def RlocationChecked(self, path: str) -> Optional[str]:
5656
def _LoadRunfiles(path: str) -> Dict[str, str]:
5757
"""Loads the runfiles manifest."""
5858
result = {}
59-
with open(path, "r") as f:
59+
with open(path, "r", encoding="utf-8", newline="\n") as f:
6060
for line in f:
6161
line = line.rstrip("\n")
6262
if line.startswith(" "):
@@ -367,7 +367,7 @@ def _ParseRepoMapping(repo_mapping_path: Optional[str]) -> Dict[Tuple[str, str],
367367
if not repo_mapping_path:
368368
return {}
369369
try:
370-
with open(repo_mapping_path, "r") as f:
370+
with open(repo_mapping_path, "r", encoding="utf-8", newline="\n") as f:
371371
content = f.read()
372372
except FileNotFoundError:
373373
return {}

0 commit comments

Comments
 (0)