From 50fcd9d1b9a20d49bc873467a82a071f2f2f8b5a Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Wed, 29 Jun 2016 15:12:03 +1200 Subject: recipetool: create: avoid decoding errors with Python 3 We're opening source files with the default encoding (utf-8) but we can't necessarily be sure that they are UTF-8 clean - for example, recipetool create ftp://mama.indstate.edu/linux/tree/tree-1.7.0.tgz prior to this patch resulted in a UnicodeDecodeError. Use the "surrogateescape" mode to avoid this. Fixes [YOCTO #9822]. Signed-off-by: Paul Eggleton Signed-off-by: Ross Burton --- scripts/lib/recipetool/create.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts/lib/recipetool/create.py') diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index 129742807f..042e7009cb 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py @@ -390,7 +390,7 @@ def create_recipe(args): srcsubdir = dirlist[0] srctree = os.path.join(srctree, srcsubdir) else: - with open(singleitem, 'r') as f: + with open(singleitem, 'r', errors='surrogateescape') as f: if '