Skip to content

Commit

Permalink
Merge pull request #185 from RekiDunois/develop
Browse files Browse the repository at this point in the history
fix: exception when news contains UTF-8 character
  • Loading branch information
xen0n authored Sep 23, 2024
2 parents d195295 + 9a8c042 commit c2384a9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ruyi/ruyipkg/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,11 @@ def ensure_news_cache(self) -> None:

cache = NewsItemStore(rs_store)
for f in glob.iglob("*.md", root_dir=news_dir):
with open(os.path.join(news_dir, f), "r") as fp:
contents = fp.read()
with open(os.path.join(news_dir, f), "r", encoding="utf-8") as fp:
try:
contents = fp.read()
except UnicodeDecodeError:
log.F(f"UnicodeDecodeError: {os.path.join(news_dir, f)}")
cache.add(f, contents) # may fail but failures are harmless

cache.finalize()
Expand Down

0 comments on commit c2384a9

Please sign in to comment.