Skip to content

Commit

Permalink
Make ctml_writer more tolerant of files with non-ascii characters
Browse files Browse the repository at this point in the history
This is an issue specifically when using Python 3 to run ctml_writer
  • Loading branch information
speth committed Oct 5, 2017
1 parent a99004d commit 0c0a38d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion interfaces/cython/cantera/ctml_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2616,9 +2616,10 @@ def convert(filename=None, outName=None, text=None):
elif outName is None:
outName = 'STDOUT'

open_kw = {'encoding': 'latin-1'} if sys.version_info.major == 3 else {}
try:
if filename is not None:
with open(filename, 'rU') as f:
with open(filename, 'rU', **open_kw) as f:
code = compile(f.read(), filename, 'exec')
else:
code = compile(text, '<string>', 'exec')
Expand Down

0 comments on commit 0c0a38d

Please sign in to comment.