Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions sasmodels/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def load_template(filename):
path = joinpath(DATA_PATH, filename)
mtime = getmtime(path)
if filename not in _template_cache or mtime > _template_cache[filename][0]:
with open(path) as fid:
with open(path, encoding="utf-8") as fid:
_template_cache[filename] = (mtime, fid.read(), path)
return _template_cache[filename][1], path

Expand Down Expand Up @@ -945,7 +945,10 @@ def _add_source(source, code, path, lineno=1):
source.append(code)

def read_text(f):
with open(f) as fid:
"""
Read a source file. Sources are UTF-8.
"""
with open(f, encoding="utf-8") as fid:
return fid.read()

def make_source(model_info):
Expand Down
2 changes: 1 addition & 1 deletion sasmodels/gengauss.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def gengauss(n, path):
else:
array_size = n

with open(path, "w") as fid:
with open(path, "w", encoding="utf-8") as fid:
fid.write(f"""\
// Generated by sasmodels.gengauss.gengauss({n})

Expand Down
4 changes: 2 additions & 2 deletions sasmodels/kerneldll.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,12 @@ def make_dll(source, model_info, dtype=F64, system=False):
basename = splitext(os.path.basename(dll))[0] + "_"
system_fd, filename = tempfile.mkstemp(suffix=".c", prefix=basename)
logging.debug("make_dll: writing C for dll: %s", filename)
with os.fdopen(system_fd, "w") as file_handle:
with os.fdopen(system_fd, "w", encoding="utf-8") as file_handle:
file_handle.write(source)
else:
filename = splitext(dll)[0] + ".c"
logging.debug("make_dll: writing C for system dll: %s", filename)
with open(filename, 'w') as file_handle:
with open(filename, 'w', encoding="utf-8") as file_handle:
file_handle.write(source)
compile_model(source=filename, output=dll)
# Comment the following to keep the generated C file.
Expand Down
2 changes: 1 addition & 1 deletion sasmodels/rst2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def load_rst_as_html(filename):
# type: (str) -> str
"""Load rst from file and convert to html"""
from os.path import expanduser
with open(expanduser(filename)) as fid:
with open(expanduser(filename), encoding="utf-8") as fid:
rst = fid.read()
html = rst2html(rst)
return html
Expand Down
Loading