[linux] 01/01: debian/bin/gencontrol.py: Set encoding to UTF-8 globally

debian-kernel at lists.debian.org debian-kernel at lists.debian.org
Fri Oct 20 01:58:45 UTC 2017


This is an automated email from the git hooks/post-receive script.

benh pushed a commit to branch master
in repository linux.

commit 2629671100af850867730c47d528f79574cda754
Author: Ben Hutchings <ben at decadent.org.uk>
Date:   Fri Oct 20 02:56:35 2017 +0100

    debian/bin/gencontrol.py: Set encoding to UTF-8 globally
    
    I just made this change for firmware-nonfree, for which I wrote:
    
        We open some, but not all, files with an explicit UTF-8 encoding.  One
        of the open calls that I missed has just caused gencontrol.py to fail
        instead a pbuilder environment.  Instead of continuing to set an
        explicit encoding for each open call, use locale.setlocale to set it
        globally.
    
    I haven't hit such a problem here, but let's do it anyway.
    
    Keep using explicit encodings in debian/lib for now, since we can't
    assume all calling programs will set the locale.
---
 debian/bin/gencontrol.py | 12 +++++++-----
 debian/changelog         |  1 +
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/debian/bin/gencontrol.py b/debian/bin/gencontrol.py
index 9e7a273..df43053 100755
--- a/debian/bin/gencontrol.py
+++ b/debian/bin/gencontrol.py
@@ -3,7 +3,7 @@
 import sys
 sys.path.append("debian/lib/python")
 
-import codecs
+import locale
 import errno
 import glob
 import io
@@ -11,6 +11,8 @@ import os
 import os.path
 import subprocess
 
+locale.setlocale(locale.LC_CTYPE, "C.UTF-8")
+
 from debian_linux import config
 from debian_linux.debian import *
 from debian_linux.gencontrol import Gencontrol as Base, merge_packages
@@ -62,7 +64,7 @@ class Gencontrol(Base):
                 makeflags[dst] = data[src]
 
     def _substitute_file(self, template, vars, target, append=False):
-        with codecs.open(target, 'a' if append else 'w', 'utf-8') as f:
+        with open(target, 'a' if append else 'w') as f:
             f.write(self.substitute(self.templates[template], vars))
 
     def do_main_setup(self, vars, makeflags, extra):
@@ -237,9 +239,9 @@ class Gencontrol(Base):
                     stdout=subprocess.PIPE,
                     env=kw_env)
                 if not isinstance(kw_proc.stdout, io.IOBase):
-                    udeb_packages = read_control(io.open(kw_proc.stdout.fileno(), encoding='utf-8', closefd=False))
+                    udeb_packages = read_control(io.open(kw_proc.stdout.fileno(), closefd=False))
                 else:
-                    udeb_packages = read_control(io.TextIOWrapper(kw_proc.stdout, 'utf-8'))
+                    udeb_packages = read_control(io.TextIOWrapper(kw_proc.stdout))
                 kw_proc.wait()
                 if kw_proc.returncode != 0:
                     raise RuntimeError('kernel-wedge exited with code %d' %
@@ -573,7 +575,7 @@ class Gencontrol(Base):
         f.close()
 
     def write_tests_control(self):
-        self.write_rfc822(codecs.open("debian/tests/control", 'w', 'utf-8'),
+        self.write_rfc822(open("debian/tests/control", 'w'),
                           [self.tests_control])
 
 if __name__ == '__main__':
diff --git a/debian/changelog b/debian/changelog
index 34be3d5..f05b574 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 linux (4.14~rc5-1~exp2) UNRELEASED; urgency=medium
 
   * [mips*] Increase RELOCATION_TABLE_SIZE to 0x00120000 (fixes FTBFS)
+  * debian/bin/gencontrol.py: Set encoding to UTF-8 globally
 
  -- Ben Hutchings <ben at decadent.org.uk>  Fri, 20 Oct 2017 00:20:35 +0100
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git



More information about the Kernel-svn-changes mailing list