1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-08-08 22:36:48 +02:00

add hexlify compatibility for python 3.6 and 3.7

This commit is contained in:
Kelly Brazil
2022-07-05 19:12:44 -07:00
parent 625544f53e
commit 855c9363a5

View File

@ -235,7 +235,12 @@ def _i2b(integer: int) -> bytes:
def _b2a(byte_string: bytes) -> str:
"""Convert a byte string to a colon-delimited hex ascii string"""
# need try/except since seperator was only introduced in python 3.8.
# provides compatibility for python 3.6 and 3.7.
try:
return binascii.hexlify(byte_string, ':').decode('utf-8')
except TypeError:
return binascii.hexlify(byte_string).decode('utf-8')
def _fix_objects(obj):