Skip to content

Commit affe6be

Browse files
authored
[sffbase] Make convert_hex_to_string() compatible with both Python 2 and Python 3 (#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 #160
1 parent c0fdfca commit affe6be

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sonic_platform_base/sonic_sfp/sffbase.py

Lines changed: 1 addition & 1 deletion
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)