From c2466c545bce1c89bed5ca6536376444d01f0522 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Thu, 14 Mar 2019 10:00:30 +1000 Subject: [PATCH] Handle binary files when scanning metadata in python 3 (#53773) --- test/runner/lib/target.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/runner/lib/target.py b/test/runner/lib/target.py index 0fac98cb04..101104257e 100644 --- a/test/runner/lib/target.py +++ b/test/runner/lib/target.py @@ -394,8 +394,12 @@ def analyze_integration_target_dependencies(integration_targets): for meta_path in meta_paths: if os.path.exists(meta_path): - with open(meta_path, 'r') as meta_fd: - meta_lines = meta_fd.read().splitlines() + with open(meta_path, 'rb') as meta_fd: + # try and decode the file as a utf-8 string, skip if it contains invalid chars (binary file) + try: + meta_lines = meta_fd.read().decode('utf-8').splitlines() + except UnicodeDecodeError: + continue for meta_line in meta_lines: if re.search(r'^ *#.*$', meta_line):