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
diff --git a/scripts/make_docs.py b/scripts/make_docs.py
index 42b499a..bb51620 100644
--- a/scripts/make_docs.py
+++ b/scripts/make_docs.py
@@ -35,6 +35,7 @@
from __future__ import print_function
import glob
+import io
import os
import sys
@@ -102,7 +103,7 @@
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 @@
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)