Use explicit check for python version (see issue #2856)

This commit is contained in:
Marshall Greenblatt
2020-01-13 11:53:36 +01:00
parent 3afa29d499
commit 1a406d079b
4 changed files with 9 additions and 16 deletions

View File

@ -32,11 +32,9 @@ def write_file(name, data):
try:
with open(name, 'w', encoding='utf-8') as f:
# write the data
try:
# Python 2
if sys.version_info.major == 2:
f.write(data.decode('utf-8'))
except Exception as e:
# Python 3
else:
f.write(data)
except IOError as e:
(errno, strerror) = e.args