Use open built-in to open files

* This makes Python 3 not raise UnicodeDecodeError when reading files
This commit is contained in:
Sviatoslav Sydorenko 2016-12-29 18:53:57 +02:00
parent 9573c13884
commit 51f8cc8ff0
6 changed files with 9 additions and 14 deletions

View file

@ -32,7 +32,7 @@ def get_line_offsets_by_line_no(src):
def fix_strings(filename):
contents = io.open(filename).read()
contents = open(filename).read()
line_offsets = get_line_offsets_by_line_no(contents)
# Basically a mutable string
@ -52,7 +52,7 @@ def fix_strings(filename):
new_contents = ''.join(splitcontents)
if contents != new_contents:
with io.open(filename, 'w') as write_handle:
with open(filename, 'w') as write_handle:
write_handle.write(new_contents)
return 1
else: