Skip to content

Commit 2047ed2

Browse files
committed
Force modelcards to use utf8 encoding (#1102)
1 parent 583d9f7 commit 2047ed2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/huggingface_hub/repocard.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def save(self, filepath: Union[Path, str]):
120120
"""
121121
filepath = Path(filepath)
122122
filepath.parent.mkdir(parents=True, exist_ok=True)
123-
filepath.write_text(str(self))
123+
filepath.write_text(str(self), encoding="utf-8")
124124

125125
@classmethod
126126
def load(
@@ -167,7 +167,7 @@ def load(
167167
)
168168

169169
# Preserve newlines in the existing file.
170-
with Path(card_path).open(mode="r", newline="") as f:
170+
with Path(card_path).open(mode="r", newline="", encoding="utf-8") as f:
171171
return cls(f.read())
172172

173173
def validate(self, repo_type: Optional[str] = None):

0 commit comments

Comments
 (0)