summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorChristian Heimes <cheimes@redhat.com>2017-02-10 14:31:10 +0100
committerMartin Basti <mbasti@redhat.com>2017-02-10 16:16:44 +0100
commite6129a76e7093b8f9f7717e5f63ed06f9e9ef30a (patch)
tree3448904e972c9f77ae7f1b0ad0f6b9e44f8fbd9b /ipalib
parent3d9bec2e879d60e6bb7b2602084d3314765a6283 (diff)
downloadfreeipa-e6129a76e7093b8f9f7717e5f63ed06f9e9ef30a.tar.gz
freeipa-e6129a76e7093b8f9f7717e5f63ed06f9e9ef30a.tar.xz
freeipa-e6129a76e7093b8f9f7717e5f63ed06f9e9ef30a.zip
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>
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/parameters.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index 073e1383e..7fbe63e69 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -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