Skip to content

Commit

Permalink
fix: don't use binary mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sujuka99 committed Nov 2, 2023
1 parent ea75e6f commit 3b31813
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hooks/gen_docs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def copy_file(
NOTE: The default header will only contain correct information if the caller of
this function is the one which should be referenced in the header
"""
with dest.open("w+b") as file_dest, source.open("rb") as file_source:
with dest.open("w+") as file_dest, source.open("r") as file_source:
if not add_header:
shutil.copyfileobj(file_source, file_dest)
return
if header is None:
header_encoded = f"<!-- This file is autogenerated by {Path(inspect.stack()[1].filename).relative_to(ROOT)}. -->\n\n".encode()
header_encoded = f"<!-- This file is autogenerated by {Path(inspect.stack()[1].filename).relative_to(ROOT)}. -->\n\n"
else:
header_encoded = header.encode()
with TemporaryFile() as file_header:
header_encoded = header
with TemporaryFile(mode="w+") as file_header:
file_header.write(header_encoded)
file_header.seek(0)
shutil.copyfileobj(file_header, file_dest)
Expand Down

0 comments on commit 3b31813

Please sign in to comment.