All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 02/17] patman: Use unicode for file I/O
Date: Thu, 31 Oct 2019 07:42:51 -0600	[thread overview]
Message-ID: <20191031074251.v2.2.Ia4a8d3ee2eeb78348b09a654f3ed7b61028932fc@changeid> (raw)
In-Reply-To: <20191031134310.3072-1-sjg@chromium.org>

At present patman test fail in some environments which don't use utf-8
as the default file encoding. Add this explicitly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Add new patch to explicitly use unicode for file I/O in patman

 tools/patman/func_test.py   | 8 ++++----
 tools/patman/patchstream.py | 4 ++--
 tools/patman/series.py      | 2 +-
 tools/patman/settings.py    | 4 ++--
 tools/patman/test.py        | 4 ++--
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 50a2741439..eadb49a335 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -51,7 +51,7 @@ class TestFunctional(unittest.TestCase):
 
     @classmethod
     def GetText(self, fname):
-        return open(self.GetPath(fname)).read()
+        return open(self.GetPath(fname), encoding='utf-8').read()
 
     @classmethod
     def GetPatchName(self, subject):
@@ -160,7 +160,7 @@ class TestFunctional(unittest.TestCase):
                     dry_run, not ignore_bad_tags, cc_file,
                     in_reply_to=in_reply_to, thread=None)
             series.ShowActions(args, cmd, process_tags)
-        cc_lines = open(cc_file).read().splitlines()
+        cc_lines = open(cc_file, encoding='utf-8').read().splitlines()
         os.remove(cc_file)
 
         lines = out[0].splitlines()
@@ -229,14 +229,14 @@ Simon Glass (2):
 2.7.4
 
 '''
-        lines = open(cover_fname).read().splitlines()
+        lines = open(cover_fname, encoding='utf-8').read().splitlines()
         self.assertEqual(
                 'Subject: [RFC PATCH v3 0/2] test: A test patch series',
                 lines[3])
         self.assertEqual(expected.splitlines(), lines[7:])
 
         for i, fname in enumerate(args):
-            lines = open(fname).read().splitlines()
+            lines = open(fname, encoding='utf-8').read().splitlines()
             subject = [line for line in lines if line.startswith('Subject')]
             self.assertEqual('Subject: [RFC %d/%d]' % (i + 1, count),
                              subject[0][:18])
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index ef06606297..df3eb7483b 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -511,8 +511,8 @@ def FixPatch(backup_dir, fname, series, commit):
         A list of errors, or [] if all ok.
     """
     handle, tmpname = tempfile.mkstemp()
-    outfd = os.fdopen(handle, 'w')
-    infd = open(fname, 'r')
+    outfd = os.fdopen(handle, 'w', encoding='utf-8')
+    infd = open(fname, 'r', encoding='utf-8')
     ps = PatchStream(series)
     ps.commit = commit
     ps.ProcessStream(infd, outfd)
diff --git a/tools/patman/series.py b/tools/patman/series.py
index 67103f03e6..95ec1d3131 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -223,7 +223,7 @@ class Series(dict):
         col = terminal.Color()
         # Look for commit tags (of the form 'xxx:' at the start of the subject)
         fname = '/tmp/patman.%d' % os.getpid()
-        fd = open(fname, 'w')
+        fd = open(fname, 'w', encoding='utf-8')
         all_ccs = []
         for commit in self.commits:
             cc = []
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index c98911d522..5dc83a8500 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -165,7 +165,7 @@ def ReadGitAliases(fname):
         fname: Filename to read
     """
     try:
-        fd = open(fname, 'r')
+        fd = open(fname, 'r', encoding='utf-8')
     except IOError:
         print("Warning: Cannot find alias file '%s'" % fname)
         return
@@ -259,7 +259,7 @@ def _ReadAliasFile(fname):
     """
     if os.path.exists(fname):
         bad_line = None
-        with open(fname) as fd:
+        with open(fname, encoding='utf-8') as fd:
             linenum = 0
             for line in fd:
                 linenum += 1
diff --git a/tools/patman/test.py b/tools/patman/test.py
index cc61c20606..889e186606 100644
--- a/tools/patman/test.py
+++ b/tools/patman/test.py
@@ -72,12 +72,12 @@ Signed-off-by: Simon Glass <sjg@chromium.org>
 '''
         out = ''
         inhandle, inname = tempfile.mkstemp()
-        infd = os.fdopen(inhandle, 'w')
+        infd = os.fdopen(inhandle, 'w', encoding='utf-8')
         infd.write(data)
         infd.close()
 
         exphandle, expname = tempfile.mkstemp()
-        expfd = os.fdopen(exphandle, 'w')
+        expfd = os.fdopen(exphandle, 'w', encoding='utf-8')
         expfd.write(expected)
         expfd.close()
 
-- 
2.24.0.rc0.303.g954a862665-goog

  parent reply	other threads:[~2019-10-31 13:42 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-31 13:42 [U-Boot] [PATCH v2 00/17] scripts: Convert to Python 3 Simon Glass
2019-10-31 13:42 ` [U-Boot] [PATCH v2 01/17] patman: Adjust 'command' to return strings instead of bytes Simon Glass
2019-10-31 13:42 ` Simon Glass [this message]
2019-10-31 13:42 ` [U-Boot] [PATCH v2 03/17] patman: Move to use Python 3 Simon Glass
2019-10-31 13:42 ` [U-Boot] [PATCH v2 04/17] buildman: Convert to " Simon Glass
2019-10-31 13:42 ` [U-Boot] [PATCH v2 05/17] test_fdt: Move to use " Simon Glass
2019-10-31 13:42 ` [U-Boot] [PATCH v2 06/17] test_dtoc: " Simon Glass
2019-10-31 13:42 ` [U-Boot] [PATCH v2 07/17] microcode_tool: Convert to " Simon Glass
2019-10-31 13:42 ` [U-Boot] [PATCH v2 08/17] move_config: " Simon Glass
2019-10-31 13:42 ` [U-Boot] [PATCH v2 09/17] rkmux: " Simon Glass
2019-10-31 13:42 ` [U-Boot] [PATCH v2 10/17] pylibfdt: " Simon Glass
2019-10-31 13:43 ` [U-Boot] [PATCH v2 11/17] pylibfdt: Sync up with upstream Simon Glass
2019-10-31 13:43 ` [U-Boot] [PATCH v2 12/17] pylibfdt: Correct the type for fdt_property_stub() Simon Glass
2019-10-31 13:43 ` [U-Boot] [PATCH v2 13/17] binman: Remember the pre-reset entry size Simon Glass
2019-10-31 13:43 ` [U-Boot] [PATCH v2 14/17] binman: Convert a few tests to Python 3 Simon Glass
2019-10-31 13:43 ` [U-Boot] [PATCH v2 15/17] dtoc: Convert fdt.py " Simon Glass
2019-10-31 13:43 ` [U-Boot] [PATCH v2 16/17] binman: Move to use " Simon Glass
2019-10-31 13:55   ` Tom Rini
2019-10-31 15:19     ` Simon Glass
2019-10-31 15:50       ` Tom Rini
2019-10-31 16:12         ` Simon Glass
2019-11-04 15:25           ` Tom Rini
2019-11-05 12:06           ` sjg at google.com
2019-10-31 13:43 ` [U-Boot] [PATCH v2 17/17] RRC: gitlab: Use Python 3 in virtualenv Simon Glass
2019-10-31 13:48   ` Tom Rini
2019-11-05 12:06 ` [U-Boot] [PATCH v2 15/17] dtoc: Convert fdt.py to Python 3 sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 14/17] binman: Convert a few tests " sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 13/17] binman: Remember the pre-reset entry size sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 12/17] pylibfdt: Correct the type for fdt_property_stub() sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 11/17] pylibfdt: Sync up with upstream sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 09/17] rkmux: Convert to Python 3 sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 10/17] pylibfdt: " sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 08/17] move_config: " sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 06/17] test_dtoc: Move to use " sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 07/17] microcode_tool: Convert to " sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 05/17] test_fdt: Move to use " sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 04/17] buildman: Convert to " sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 03/17] patman: Move to use " sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 02/17] patman: Use unicode for file I/O sjg at google.com
2019-11-05 12:06 ` [U-Boot] [PATCH v2 01/17] patman: Adjust 'command' to return strings instead of bytes sjg at google.com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191031074251.v2.2.Ia4a8d3ee2eeb78348b09a654f3ed7b61028932fc@changeid \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.