utils: Test remote_addr as bytes, not str
This was probably an oversight while porting to py2-only:
python2 support was removed in
Checking for not(str) and str at the same time is a no-op.
What makes sense is to check whether a byte object can be
decoded to unicode.
@@ -19,7 +19,7 @@ def anonymize(remote_addr):
and /48 (zero'd).
"""
- if not isinstance(remote_addr, str) and isinstance(remote_addr, str):
+ if isinstance(remote_addr, bytes):
remote_addr = remote_addr.decode('ascii', 'ignore')
try:
ipv4 = ipaddress.IPv4Address(remote_addr)
