patman: Handle invalid characters in patch files
In some cases latin1 encoding may be used in source files. If
'high-ascii' are used, patman may report an error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in
position 1051: invalid continuation byte
Fix this by replacing these characters. This may cause the patch to fail
to apply, but at least it can be checked.
Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -831,7 +831,7 @@ def fix_patch(backup_dir, fname, series, cmt, keep_change_id=False,
|
||||
fname = os.path.join(cwd or '', fname)
|
||||
handle, tmpname = tempfile.mkstemp()
|
||||
outfd = os.fdopen(handle, 'w', encoding='utf-8')
|
||||
infd = open(fname, 'r', encoding='utf-8')
|
||||
infd = open(fname, 'r', encoding='utf-8', errors='replace')
|
||||
pst = PatchStream(series, keep_change_id=keep_change_id,
|
||||
insert_base_commit=insert_base_commit)
|
||||
pst.commit = cmt
|
||||
|
||||
Reference in New Issue
Block a user