[rtems-docs commit] waf/common: Fix UTF-8 encoding of HTML inliner output on Python3.

Chris Johns chrisj at rtems.org
Tue Oct 29 02:42:57 UTC 2019


Module:    rtems-docs
Branch:    master
Commit:    c576e9bf0df78f02fbf46e126aa7a8caae75b567
Changeset: http://git.rtems.org/rtems-docs/commit/?id=c576e9bf0df78f02fbf46e126aa7a8caae75b567

Author:    Chris Johns <chrisj at rtems.org>
Date:      Tue Oct 29 13:37:43 2019 +1100

waf/common: Fix UTF-8 encoding of HTML inliner output on Python3.

---

 common/waf.py | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

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
 



More information about the vc mailing list