diff --git a/scripts/MakeHeader.py b/scripts/MakeHeader.py index 2393afc2..5299d0ed 100755 --- a/scripts/MakeHeader.py +++ b/scripts/MakeHeader.py @@ -1,12 +1,9 @@ #!/usr/bin/env python -import os, sys, string +import os, sys, string, io try: - from cStringIO import StringIO + from StringIO import StringIO except ImportError: - try: - from StringIO import StringIO - except ImportError: - from io import StringIO + from io import StringIO ANY=1 COPY=2 @@ -17,7 +14,7 @@ COPYDEFINE=5 state = ANY static = 0 -file = open(sys.argv[1]) +file = io.open(sys.argv[1], "r", encoding="utf-8") name = sys.argv[1][:-2] out = StringIO() @@ -104,12 +101,12 @@ out.write( "#endif\n" ) # This prevents a lot of recompilation during development out.seek(0) try: - with open(name + ".h", "r") as orig: + with io.open(name + ".h", "r", encoding="utf-8") as orig: origcontents = orig.readlines() except: origcontents = "" if origcontents != out.readlines(): - with open(name + ".h", "w") as new: + with io.open(name + ".h", "w", encoding="utf-8") as new: print("Writing "+name+".h") new.write(out.getvalue()) out.close()