dnsutil: Rename __nonzero__ to __bool__

In Python 3, this special method got renamed. Set both to the same
function to keep compatibility.

https://fedorahosted.org/freeipa/ticket/5623

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Petr Viktorin
2016-01-20 11:59:21 +01:00
committed by Jan Cholasta
parent 06a678c159
commit 983c53bb6c
+3 -1
View File
@@ -49,11 +49,13 @@ class DNSName(dns.name.Name):
# instead of a dns.exception # instead of a dns.exception
raise dns.exception.SyntaxError(e) raise dns.exception.SyntaxError(e)
def __nonzero__(self): def __bool__(self):
#dns.name.from_text('@') is represented like empty tuple #dns.name.from_text('@') is represented like empty tuple
#we need to acting '@' as nonzero value #we need to acting '@' as nonzero value
return True return True
__nonzero__ = __bool__ # for Python 2
def __copy__(self): def __copy__(self):
return DNSName(self.labels) return DNSName(self.labels)