Skip to content

Commit

Permalink
fix: Avoid crash when file in repo contains non-unicode characters (#59)
Browse files Browse the repository at this point in the history
This fix prevents a crash when using `--clean` on a repo where a file
contains non-unicode characters. Fix seems benign since any file with
non-unicode characters likely wasnt created by this tool.

Closes #58

---------

Co-authored-by: Bradley Dice <[email protected]>
  • Loading branch information
difyrrwrzd and bdice authored Dec 13, 2023
1 parent ae0fc61 commit f178845
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ def delete_existing_files(root="."):
lambda fn: fn.endswith(".txt") or fn.endswith(".yaml"), filenames
):
with open(file_path := os.path.join(dirpath, fn)) as f:
if HEADER in f.read():
os.remove(file_path)
try:
if HEADER in f.read():
os.remove(file_path)
except UnicodeDecodeError:
pass


def dedupe(dependencies):
Expand Down

0 comments on commit f178845

Please sign in to comment.