From 2ad14b7a616c8e95f269e188a2e29ea832b03f7b Mon Sep 17 00:00:00 2001 From: Niels Ole Salscheider Date: Wed, 2 Mar 2016 21:55:37 +0100 Subject: [PATCH] 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 --- scripts/make_docs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/make_docs.py b/scripts/make_docs.py index 42b499a48..bb5162053 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 @@ 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)