mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-04-01 03:51:31 +00:00
patman: Use unicode for file I/O
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>
This commit is contained in:
parent
3b3e3c0f6c
commit
272cd85deb
5 changed files with 11 additions and 11 deletions
|
@ -51,7 +51,7 @@ class TestFunctional(unittest.TestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def GetText(self, fname):
|
def GetText(self, fname):
|
||||||
return open(self.GetPath(fname)).read()
|
return open(self.GetPath(fname), encoding='utf-8').read()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def GetPatchName(self, subject):
|
def GetPatchName(self, subject):
|
||||||
|
@ -160,7 +160,7 @@ class TestFunctional(unittest.TestCase):
|
||||||
dry_run, not ignore_bad_tags, cc_file,
|
dry_run, not ignore_bad_tags, cc_file,
|
||||||
in_reply_to=in_reply_to, thread=None)
|
in_reply_to=in_reply_to, thread=None)
|
||||||
series.ShowActions(args, cmd, process_tags)
|
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)
|
os.remove(cc_file)
|
||||||
|
|
||||||
lines = out[0].splitlines()
|
lines = out[0].splitlines()
|
||||||
|
@ -229,14 +229,14 @@ Simon Glass (2):
|
||||||
2.7.4
|
2.7.4
|
||||||
|
|
||||||
'''
|
'''
|
||||||
lines = open(cover_fname).read().splitlines()
|
lines = open(cover_fname, encoding='utf-8').read().splitlines()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Subject: [RFC PATCH v3 0/2] test: A test patch series',
|
'Subject: [RFC PATCH v3 0/2] test: A test patch series',
|
||||||
lines[3])
|
lines[3])
|
||||||
self.assertEqual(expected.splitlines(), lines[7:])
|
self.assertEqual(expected.splitlines(), lines[7:])
|
||||||
|
|
||||||
for i, fname in enumerate(args):
|
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')]
|
subject = [line for line in lines if line.startswith('Subject')]
|
||||||
self.assertEqual('Subject: [RFC %d/%d]' % (i + 1, count),
|
self.assertEqual('Subject: [RFC %d/%d]' % (i + 1, count),
|
||||||
subject[0][:18])
|
subject[0][:18])
|
||||||
|
|
|
@ -511,8 +511,8 @@ def FixPatch(backup_dir, fname, series, commit):
|
||||||
A list of errors, or [] if all ok.
|
A list of errors, or [] if all ok.
|
||||||
"""
|
"""
|
||||||
handle, tmpname = tempfile.mkstemp()
|
handle, tmpname = tempfile.mkstemp()
|
||||||
outfd = os.fdopen(handle, 'w')
|
outfd = os.fdopen(handle, 'w', encoding='utf-8')
|
||||||
infd = open(fname, 'r')
|
infd = open(fname, 'r', encoding='utf-8')
|
||||||
ps = PatchStream(series)
|
ps = PatchStream(series)
|
||||||
ps.commit = commit
|
ps.commit = commit
|
||||||
ps.ProcessStream(infd, outfd)
|
ps.ProcessStream(infd, outfd)
|
||||||
|
|
|
@ -223,7 +223,7 @@ class Series(dict):
|
||||||
col = terminal.Color()
|
col = terminal.Color()
|
||||||
# Look for commit tags (of the form 'xxx:' at the start of the subject)
|
# Look for commit tags (of the form 'xxx:' at the start of the subject)
|
||||||
fname = '/tmp/patman.%d' % os.getpid()
|
fname = '/tmp/patman.%d' % os.getpid()
|
||||||
fd = open(fname, 'w')
|
fd = open(fname, 'w', encoding='utf-8')
|
||||||
all_ccs = []
|
all_ccs = []
|
||||||
for commit in self.commits:
|
for commit in self.commits:
|
||||||
cc = []
|
cc = []
|
||||||
|
|
|
@ -165,7 +165,7 @@ def ReadGitAliases(fname):
|
||||||
fname: Filename to read
|
fname: Filename to read
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
fd = open(fname, 'r')
|
fd = open(fname, 'r', encoding='utf-8')
|
||||||
except IOError:
|
except IOError:
|
||||||
print("Warning: Cannot find alias file '%s'" % fname)
|
print("Warning: Cannot find alias file '%s'" % fname)
|
||||||
return
|
return
|
||||||
|
@ -259,7 +259,7 @@ def _ReadAliasFile(fname):
|
||||||
"""
|
"""
|
||||||
if os.path.exists(fname):
|
if os.path.exists(fname):
|
||||||
bad_line = None
|
bad_line = None
|
||||||
with open(fname) as fd:
|
with open(fname, encoding='utf-8') as fd:
|
||||||
linenum = 0
|
linenum = 0
|
||||||
for line in fd:
|
for line in fd:
|
||||||
linenum += 1
|
linenum += 1
|
||||||
|
|
|
@ -72,12 +72,12 @@ Signed-off-by: Simon Glass <sjg@chromium.org>
|
||||||
'''
|
'''
|
||||||
out = ''
|
out = ''
|
||||||
inhandle, inname = tempfile.mkstemp()
|
inhandle, inname = tempfile.mkstemp()
|
||||||
infd = os.fdopen(inhandle, 'w')
|
infd = os.fdopen(inhandle, 'w', encoding='utf-8')
|
||||||
infd.write(data)
|
infd.write(data)
|
||||||
infd.close()
|
infd.close()
|
||||||
|
|
||||||
exphandle, expname = tempfile.mkstemp()
|
exphandle, expname = tempfile.mkstemp()
|
||||||
expfd = os.fdopen(exphandle, 'w')
|
expfd = os.fdopen(exphandle, 'w', encoding='utf-8')
|
||||||
expfd.write(expected)
|
expfd.write(expected)
|
||||||
expfd.close()
|
expfd.close()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue