chore: make apply_all_patches.py work in both python2 and python3 (#19872)

This commit is contained in:
Charles Kerr 2019-08-23 17:48:27 -05:00 committed by Samuel Attard
parent 81e9dab52f
commit ef6d4a46c2
3 changed files with 4 additions and 3 deletions

View file

@ -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))