Commit ddad9533 authored by Stefan Behnel's avatar Stefan Behnel

revert to using codecs.open() for output files instead of io.open() as the...

revert to using codecs.open() for output files instead of io.open() as the latter cannot write str objects in text mode under Py2 (and we erroneously do that in some spots)
parent f2d9322f
...@@ -7,6 +7,7 @@ import os ...@@ -7,6 +7,7 @@ import os
import sys import sys
import re import re
import io import io
import codecs
modification_time = os.path.getmtime modification_time = os.path.getmtime
...@@ -49,7 +50,9 @@ def open_new_file(path): ...@@ -49,7 +50,9 @@ def open_new_file(path):
# ASCII strings or (e.g. for file names) byte encoded strings as # ASCII strings or (e.g. for file names) byte encoded strings as
# Unicode, so we need a direct mapping from the first 256 Unicode # Unicode, so we need a direct mapping from the first 256 Unicode
# characters to a byte sequence, which ISO-8859-1 provides # characters to a byte sequence, which ISO-8859-1 provides
return io.open(path, "w", encoding="ISO-8859-1")
# note: can't use io.open() in Py2 as we may be writing str objects
return codecs.open(path, "w", encoding="ISO-8859-1")
def castrate_file(path, st): def castrate_file(path, st):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment