diff options
author | Jordan Borean <jborean93@gmail.com> | 2019-03-14 10:00:30 +1000 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2019-03-18 14:34:27 -0700 |
commit | 19dfb2f396dff9efaba909357ed196864c2a57d7 (patch) | |
tree | def3fd25a9a16c27d503a6f38a9c6f527d0c279e | |
parent | a36b86c0c00bfa34a17976b031631f4e42407272 (diff) | |
download | ansible-19dfb2f396dff9efaba909357ed196864c2a57d7.tar.gz |
Handle binary files when scanning metadata in python 3 (#53773)
(cherry picked from commit c2466c545bce1c89bed5ca6536376444d01f0522)
-rw-r--r-- | test/runner/lib/target.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/runner/lib/target.py b/test/runner/lib/target.py index b363c4a0e5..4971c07aec 100644 --- a/test/runner/lib/target.py +++ b/test/runner/lib/target.py @@ -363,8 +363,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): |