py3: Ensure read_string_from_net always returns bytes

This commit is contained in:
Kovid Goyal 2019-04-19 12:27:02 +05:30
parent 41b3705925
commit fc5fb1ddf6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -578,7 +578,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
# Things get trashed if we don't make a copy of the data. # Things get trashed if we don't make a copy of the data.
v = self._read_binary_from_net(2) v = self._read_binary_from_net(2)
if len(v) == 0: if len(v) == 0:
return '' # documentation says the socket is broken permanently. return b'' # documentation says the socket is broken permanently.
data += v data += v
total_len = int(data[:dex]) total_len = int(data[:dex])
data = data[dex:] data = data[dex:]
@ -586,7 +586,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
while pos < total_len: while pos < total_len:
v = self._read_binary_from_net(total_len - pos) v = self._read_binary_from_net(total_len - pos)
if len(v) == 0: if len(v) == 0:
return '' # documentation says the socket is broken permanently. return b'' # documentation says the socket is broken permanently.
data += v data += v
pos += len(v) pos += len(v)
return data return data