make_docs: Pass the file encoding to open()

Otherwise, it will fail on Python 3 with:
"UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
7690: ordinal not in range(128)"

We have to use io.open() instead of open(), because open() does not
accept the encoding on Python 2.

Change-Id: I77b6552491e8de01d79a26d2f146ddbd968cce49
This commit is contained in:
Niels Ole Salscheider
2016-03-02 21:55:37 +01:00
parent 7d670209a2
commit 2ad14b7a61
+3 -2
View File
@@ -35,6 +35,7 @@
from __future__ import print_function
import glob
import io
import os
import sys
@@ -102,7 +103,7 @@ breadcrumb_end = \
for name in glob.glob('%s/*.html' % html_dir):
print('Postprocessing: ', name)
with open(name) as fptr:
with io.open(name, encoding="utf-8") as fptr:
out = fptr.read()
for input_pattern, output_pattern in replacements:
@@ -119,5 +120,5 @@ for name in glob.glob('%s/*.html' % html_dir):
except ValueError:
print('Skipping breadcrumb strip for', name)
with open(name, 'w') as fptr:
with io.open(name, 'w', encoding="utf-8") as fptr:
fptr.write(out)