diff --git a/script/apply_all_patches.py b/script/apply_all_patches.py index f57c8db72f73..069422ecdd45 100755 --- a/script/apply_all_patches.py +++ b/script/apply_all_patches.py @@ -11,7 +11,7 @@ from lib.patches import patch_from_dir def apply_patches(dirs): threeway = os.environ.get("ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES") - for patch_dir, repo in dirs.iteritems(): + for patch_dir, repo in dirs.items(): git.import_patches(repo=repo, patch_data=patch_from_dir(patch_dir), threeway=threeway is not None, committer_name="Electron Scripts", committer_email="scripts@electron") diff --git a/script/lib/git.py b/script/lib/git.py index c7deb20439f5..d391f64d0973 100644 --- a/script/lib/git.py +++ b/script/lib/git.py @@ -61,7 +61,7 @@ def am(repo, patch_data, threeway=False, directory=None, exclude=None, proc = subprocess.Popen( command, stdin=subprocess.PIPE) - proc.communicate(patch_data) + proc.communicate(patch_data.encode('utf-8')) if proc.returncode != 0: raise RuntimeError("Command {} returned {}".format(command, proc.returncode)) diff --git a/script/lib/patches.py b/script/lib/patches.py index 92533b45dab9..68035f169bc1 100644 --- a/script/lib/patches.py +++ b/script/lib/patches.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import codecs import os @@ -7,7 +8,7 @@ def read_patch(patch_dir, patch_filename): """Read a patch from |patch_dir/filename| and amend the commit message with metadata about the patch file it came from.""" ret = [] - with open(os.path.join(patch_dir, patch_filename)) as f: + with codecs.open(os.path.join(patch_dir, patch_filename), encoding='utf-8') as f: for l in f.readlines(): if l.startswith('diff -'): ret.append('Patch-Filename: {}\n'.format(patch_filename))