Skip to content

Commit

Permalink
Avoid crash when file in repo contains non-unicode characters
Browse files Browse the repository at this point in the history
  • Loading branch information
mdemoret-nv authored Dec 13, 2023
1 parent 78ca9ec commit 1d673aa
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ def delete_existing_files(root="."):
for fn in filter(
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:
with open(file_path := os.path.join(dirpath, fn)) as f:
if HEADER in f.read():
os.remove(file_path)
except UnicodeDecodeError:
pass


def dedupe(dependencies):
Expand Down

0 comments on commit 1d673aa

Please sign in to comment.