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-05 14:03:50 +01:00
committed by Jan Cholasta
parent 06a678c159
commit 983c53bb6c

View File

@@ -49,11 +49,13 @@ class DNSName(dns.name.Name):
# instead of a dns.exception
raise dns.exception.SyntaxError(e)
def __nonzero__(self):
def __bool__(self):
#dns.name.from_text('@') is represented like empty tuple
#we need to acting '@' as nonzero value
return True
__nonzero__ = __bool__ # for Python 2
def __copy__(self):
return DNSName(self.labels)