Make ctml_writer more tolerant of files with non-ascii characters

This is an issue specifically when using Python 3 to run ctml_writer
This commit is contained in:
Ray Speth 2017-10-04 18:17:54 -04:00
parent a99004d8ef
commit 0c0a38d4fe

View file

@ -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')