Stable _is_null check

Avoid comparison of bytes with int in _is_null() check. b'' == 0
triggers a BytesWarning.

Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Christian Heimes 2017-02-10 14:31:10 +01:00 committed by Martin Basti
parent 3d9bec2e87
commit e6129a76e7

View File

@ -123,7 +123,13 @@ from ipapython.dnsutil import DNSName
def _is_null(value):
return not value and value != 0 # NOTE: False == 0
if value:
return False
elif isinstance(value, six.integer_types + (float, decimal.Decimal)):
# 0 is not NULL
return False
else:
return True
if six.PY3:
unicode = str