lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: output-distance: write HTML as UTF-8 (issue 563810043 by address@hid


From: hanwenn
Subject: Re: output-distance: write HTML as UTF-8 (issue 563810043 by address@hidden)
Date: Fri, 03 Apr 2020 15:15:06 -0700

Reviewers: dak,

Message:
On 2020/04/03 22:00:02, dak wrote:
> Is this likely related to the problems in `make check` that James
currently
> experiences?

Yes. 

Unfortunately, the default encoding depends on the environment

"
    In text mode, if encoding is not specified the encoding used is
platform
    dependent: locale.getpreferredencoding(False) is called to get the

"

this means that -depending on locale settings- you may get ascii or
utf-8 encoding.

I didn't get a problem at first, but if I set encoding='ascii' in the
open_write_file definition, I also get encoding errors.

Description:
output-distance: write HTML as UTF-8

This should avoid encoding errors on writing data

Please review this at https://codereview.appspot.com/563810043/

Affected files (+3, -3 lines):
  M scripts/build/output-distance.py


Index: scripts/build/output-distance.py
diff --git a/scripts/build/output-distance.py b/scripts/build/output-distance.py
index 
685f082da69687d52686d957cd90f265f40009e9..2f772fce4f4edd0216179cab555feddc30ca1091
 100755
--- a/scripts/build/output-distance.py
+++ b/scripts/build/output-distance.py
@@ -1,4 +1,5 @@
 #!@PYTHON@
+# -*- coding: utf-8 -*-
 
 import codecs
 import difflib
@@ -1252,7 +1253,6 @@ td:empty {
         dest_file = dest_dir + '/index.html'
         open_write_file (dest_file).write (html)
 
-
         for link in changed:
             link.link_files_for_html (dest_dir)
 
@@ -1302,7 +1302,7 @@ def open_write_file (x):
     log_verbose('writing %s' % x)
     d = os.path.split (x)[0]
     mkdir (d)
-    return open (x, 'w')
+    return open (x, 'w', encoding="utf-8")
 
 
 def test_paired_files ():
@@ -1325,7 +1325,7 @@ def test_compare_tree_pairs ():
     system ('mkdir -p dir1/subdir/ dir2/subdir/')
     system ('cp 19.sub{-*.signature,.ly,-1.eps,.log,.profile} dir1/subdir/')
     system ('cp 19.sub{-*.signature,.ly,-1.eps,.log,.profile} dir2/subdir/')
-    system ('echo HEAD is 1 > dir1/tree.gittxt')
+    system (u'echo HEAD is 人人的乐谱软件 > dir1/tree.gittxt')
     system ('echo HEAD is 2 > dir2/tree.gittxt')
 
     ## introduce differences





reply via email to

[Prev in Thread] Current Thread [Next in Thread]