diff mbox series

[v2,2/8] docker.py/build: support binary files in --extra-files

Message ID 20200521124535.5329-3-pbonzini@redhat.com
State New
Headers show
Series run-coverity-scan: misc improvements, especially for docker mode | expand

Commit Message

Paolo Bonzini May 21, 2020, 12:45 p.m. UTC
Read the --extra-files in binary mode to avoid encoding errors.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
 tests/docker/docker.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index ad61747bae..85e1dda10f 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -56,15 +56,19 @@  class EngineEnum(enum.IntEnum):
+def _bytes_checksum(bytes):
+    """Calculate a digest string unique to the text content"""
+    return hashlib.sha1(bytes).hexdigest()
 def _text_checksum(text):
     """Calculate a digest string unique to the text content"""
-    return hashlib.sha1(text.encode('utf-8')).hexdigest()
+    return _bytes_checksum(text.encode('utf-8'))
 def _read_dockerfile(path):
     return open(path, 'rt', encoding='utf-8').read()
 def _file_checksum(filename):
-    return _text_checksum(_read_dockerfile(filename))
+    return _bytes_checksum(open(filename, 'rb').read())
 def _guess_engine_command():