From 558d8cf7cd971c024a1eee0221e0dc1c952039f0 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 26 Aug 2020 21:13:29 +0100 Subject: Migrate Python code to Python 3. --- makecab.py | 30 ++++++++++++++++-------------- wrapper.py | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/makecab.py b/makecab.py index 77c1e4f..e9ad9d0 100755 --- a/makecab.py +++ b/makecab.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import os @@ -10,7 +10,7 @@ from collections import namedtuple CFHEADER_s = struct.Struct("<4sLLLLLBBHHHHH") CFHEADER = namedtuple("CFHEADER", "sig res0 size res1 firstfile res2 " "verminor vermajor folders files flags setid icabinet") -CFHEADER_sig = "MSCF" +CFHEADER_sig = b"MSCF" CFFOLDER_s = struct.Struct("> 1)) def checksum(data): - data_full_words = data[:len(data) & ~3] - data_last_word = data[len(data_full_words):] - data_last_word = "".join(reversed(data_last_word)) - data_last_word += "\0" * (3 & -len(data)) # pad to multiple of 4 bytes - data = data_full_words + data_last_word + data_fullwords_len = len(data) & ~3 + data_last_word = data[data_fullwords_len:] + data_last_word = bytes(reversed(data_last_word)) + data_last_word += b"\0" * (3 & -len(data)) # pad to multiple of 4 bytes toret = 0 - for offset in xrange(0, len(data), 4): - toret ^= struct.unpack_from("