diff --git a/lib/ansible/modules/files/unarchive.py b/lib/ansible/modules/files/unarchive.py index 8db9f0dd2ff..195e8716984 100644 --- a/lib/ansible/modules/files/unarchive.py +++ b/lib/ansible/modules/files/unarchive.py @@ -172,7 +172,7 @@ BUFSIZE = 65536 def crc32(path): ''' Return a CRC32 checksum of a file ''' - return binascii.crc32(open(path).read()) & 0xffffffff + return binascii.crc32(open(path, 'rb').read()) & 0xffffffff def shell_escape(string): ''' Quote meta-characters in the args for the unix shell ''' @@ -221,7 +221,7 @@ class ZipArchive(object): for line in out.splitlines()[3:-2]: fields = line.split(None, 7) self._files_in_archive.append(fields[7]) - self._infodict[fields[7]] = long(fields[6]) + self._infodict[fields[7]] = int(fields[6]) def _crc32(self, path): if self._infodict: @@ -240,7 +240,7 @@ class ZipArchive(object): else: try: for item in archive.infolist(): - self._infodict[item.filename] = long(item.CRC) + self._infodict[item.filename] = int(item.CRC) except: archive.close() raise UnarchiveError('Unable to list files in the archive') @@ -803,6 +803,7 @@ def main(): # If download fails, raise a proper exception if rsp is None: raise Exception(info['msg']) + # open in binary mode for python3 f = open(package, 'wb') # Read 1kb at a time to save on ram