From 8bb62fb82de0ce51e610d17c7e35467ac1e3b69b Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Mon, 1 Oct 2018 16:20:42 +1300 Subject: [PATCH] update: allow patch parsing to work with python 2 If we want to be able to read in patch information on python2-based branches (e.g. fido) then we need to use codecs.open() instead of open() here since python2's open() did not support the encoding parameter. Signed-off-by: Paul Eggleton --- layerindex/update_layer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py index 5c11b1e..42b618f 100644 --- a/layerindex/update_layer.py +++ b/layerindex/update_layer.py @@ -17,6 +17,7 @@ import re import tempfile import shutil import errno +import codecs from distutils.version import LooseVersion import itertools import utils @@ -77,7 +78,7 @@ def collect_patch(recipe, patchfn, layerdir_start, stop_on_error): try: for encoding in ['utf-8', 'latin-1']: try: - with open(patchfn, 'r', encoding=encoding) as f: + with codecs.open(patchfn, 'r', encoding=encoding) as f: for line in f: line = line.rstrip() if line.startswith('Index: ') or line.startswith('diff -') or line.startswith('+++ '):