From c576e9bf0df78f02fbf46e126aa7a8caae75b567 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Tue, 29 Oct 2019 13:37:43 +1100 Subject: waf/common: Fix UTF-8 encoding of HTML inliner output on Python3. --- common/waf.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/waf.py b/common/waf.py index d71541e..066048d 100644 --- a/common/waf.py +++ b/common/waf.py @@ -359,12 +359,20 @@ def doc_singlehtml(ctx, source_dir, conf_dir, sources): # The inliner does not handle internal href's correctly and places the # input's file name in the href. Strip these. # - with open(tgt, 'r') as i: - before = i.read() - after = before.replace('index.html', '') + if sys.version_info[0] < 3: + with open(tgt, 'r') as i: + before = i.read() + else: + with open(tgt, 'r', encoding = 'ascii', errors = 'surrogateescape') as i: + before = i.read() i.close() - with open(tgt, 'w') as o: - o.write(after) + after = before.replace('index.html', '') + if sys.version_info[0] < 3: + with open(tgt, 'w') as o: + o.write(after) + else: + with open(tgt, 'w', encoding = 'ascii', errors = 'surrogateescape') as o: + o.write(after) o.close() return r -- cgit v1.2.3