From 9bc2f62c80363d2330bc562ff19f537bf6613233 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Wed, 27 Jun 2018 14:34:24 +0100 Subject: [PATCH] [Py3] Fix tranfer header first byte check The index of a byte in Python 3 will return an integer so use slice for compatibility with 2/3 --- deluge/transfer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deluge/transfer.py b/deluge/transfer.py index c276df440..23bf98290 100644 --- a/deluge/transfer.py +++ b/deluge/transfer.py @@ -95,8 +95,8 @@ class DelugeTransferProtocol(Protocol, object): # Read the first bytes of the message (MESSAGE_HEADER_SIZE bytes) header = self._buffer[:MESSAGE_HEADER_SIZE] payload_len = header[1:MESSAGE_HEADER_SIZE] - if header[0] != b'D': - raise Exception('Invalid header format. First byte is %d' % ord(header[0])) + if header[0:1] != b'D': + raise Exception('Invalid header format. First byte is %d' % ord(header[0:1])) # Extract the length stored as a signed integer (using 4 bytes) self._message_length = struct.unpack('!i', payload_len)[0] if self._message_length < 0: