Skip to content

Commit

Permalink
Use UTF-8 for file reading/writing (#1937)
Browse files Browse the repository at this point in the history
- Read `VERSION.txt` using UTF-8
- Read and write replay JSON using UTF-8
  • Loading branch information
rmartin16 committed Sep 21, 2023
1 parent f4faa86 commit 9017b8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cookiecutter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def _get_version() -> str:
"""Read VERSION.txt and return its contents."""
path = Path(__file__).parent.resolve()
version_file = path / "VERSION.txt"
return version_file.read_text().strip()
return version_file.read_text(encoding="utf-8").strip()


__version__ = _get_version()
4 changes: 2 additions & 2 deletions cookiecutter/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def dump(replay_dir: "os.PathLike[str]", template_name: str, context: dict):

replay_file = get_file_name(replay_dir, template_name)

with open(replay_file, 'w') as outfile:
with open(replay_file, 'w', encoding="utf-8") as outfile:
json.dump(context, outfile, indent=2)


Expand All @@ -42,7 +42,7 @@ def load(replay_dir, template_name):

replay_file = get_file_name(replay_dir, template_name)

with open(replay_file) as infile:
with open(replay_file, encoding="utf-8") as infile:
context = json.load(infile)

if 'cookiecutter' not in context:
Expand Down

0 comments on commit 9017b8d

Please sign in to comment.