Fix _compat for py3

This commit is contained in:
twangboy 2019-02-28 15:38:26 -07:00
parent 2ebfa22f87
commit 2837bb9c17
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB

View file

@ -190,7 +190,10 @@ class IPv6AddressScoped(ipaddress.IPv6Address):
packed = False
if isinstance(data, bytes) and len(data) == 16 and b':' not in data:
try:
packed = bool(int(str(bytearray(data)).encode('hex'), 16))
if PY3:
packed = bool(int(str(bytearray(data, 'utf-8')).encode('utf-8').hex(), 16))
else:
packed = bool(int(str(bytearray(data)).encode('hex'), 16))
except ValueError:
pass