Skip to content

Commit 513920c

Browse files
committed
[sffbase] Make convert_hex_to_string() compatible with both Python 2 and Python 3 (sonic-net#165)
When called with Python 3, `str.strip(binascii.unhexlify(ret_str))` will raise an exception: ` descriptor 'strip' requires a 'str' object but received a 'bytes'`. This patch (`binascii.unhexlify(ret_str).decode("utf-8").strip()`) will work properly with both Python 2 and Python 3. Fixes sonic-net/sonic-platform-common#160
1 parent bd4dc03 commit 513920c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sonic_platform_base/sonic_sfp/sffbase.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def convert_hex_to_string(self, arr, start, end):
3535
ret_str = ''
3636
for n in range(start, end):
3737
ret_str += arr[n]
38-
return str.strip(binascii.unhexlify(ret_str))
38+
return binascii.unhexlify(ret_str).decode("utf-8").strip()
3939
except Exception as err:
4040
return str(err)
4141

0 commit comments

Comments
 (0)