Skip to content

Commit

Permalink
Don't use encoding when in binary mode
Browse files Browse the repository at this point in the history
  • Loading branch information
RatishT committed Jun 28, 2024
1 parent c4f4cbe commit 00ff4d0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion forge/forge/file_storage/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ def _open_file(self, path: str | Path, mode: str) -> TextIO | BinaryIO:
full_path = self.get_path(path)
if any(m in mode for m in ("w", "a", "x")):
full_path.parent.mkdir(parents=True, exist_ok=True)
return open(full_path, mode, encoding='utf-8')
if 'b' in mode:
return open(full_path, mode)
else:
return open(full_path, mode, encoding='utf-8')

@overload
def read_file(self, path: str | Path, binary: Literal[False] = False) -> str:
Expand Down

0 comments on commit 00ff4d0

Please sign in to comment.