Skip to content

Commit f6a08c6

Browse files
Handle non-UTF8 encodings in add_readme existing file check
1 parent a010465 commit f6a08c6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/usethis/_core/readme.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ def add_readme() -> None:
2323
pass
2424
else:
2525
# Check if the file is non-empty; if so, we will exit early
26-
existing_content = path.read_text().strip()
27-
if existing_content:
26+
try:
27+
existing_content = path.read_text(encoding="utf-8")
28+
except UnicodeDecodeError:
29+
return
30+
if existing_content.strip():
2831
return
2932

3033
project_name = get_project_name()

0 commit comments

Comments
 (0)