Skip to content

Commit

Permalink
specify encodings for open()
Browse files Browse the repository at this point in the history
  • Loading branch information
whoburg committed Jan 5, 2024
1 parent 7c6121a commit d1c3433
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gpkit/build.py
Expand Up @@ -51,8 +51,8 @@ def call(cmd):

def diff(filename, diff_dict):
"Applies a simple diff to a file. Logs."
with open(filename, "r") as a:
with open(filename+".new", "w") as b:
with open(filename, "r", encoding="UTF-8") as a:
with open(filename+".new", "w", encoding="UTF-8") as b:
for line_number, line in enumerate(a):
if line[:-1].strip() in diff_dict:
newline = diff_dict[line[:-1].strip()]+"\n"
Expand Down Expand Up @@ -193,10 +193,10 @@ def build():
# Write settings
envpath = "env"
replacedir(envpath)
with open(pathjoin(envpath, "settings"), "w") as f:
with open(pathjoin(envpath, "settings"), "w", encoding="UTF-8") as f:
for setting, value in sorted(settings.items()):
f.write(f"{setting} : {value}\n")
with open(pathjoin(envpath, "build.log"), "w") as f:
with open(pathjoin(envpath, "build.log"), "w", encoding="UTF-8") as f:
f.write(LOGSTR)

os.chdir(start_dir)
Expand Down

0 comments on commit d1c3433

Please sign in to comment.