diff options
author | Martin Basti <mbasti@redhat.com> | 2016-12-14 10:12:05 +0100 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2017-01-06 12:48:10 +0100 |
commit | 35ba724de90b270773d91596de310291df745df0 (patch) | |
tree | 93c8e02f6228baaa0a65da5902a99ae068571f12 /ipapython | |
parent | deaad95247fa9624bef0108bf3813f358fb17ee5 (diff) | |
download | freeipa-35ba724de90b270773d91596de310291df745df0.tar.gz freeipa-35ba724de90b270773d91596de310291df745df0.tar.xz freeipa-35ba724de90b270773d91596de310291df745df0.zip |
Py3: Fix ToASCII method
in Py2 to_text method returns Py2 non-unicode string, but in Py3 to_text method
returns Py3 default (unicode) string. So only in Py2 we have to decode
str to unicode.
https://fedorahosted.org/freeipa/ticket/5935
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r-- | ipapython/dnsutil.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ipapython/dnsutil.py b/ipapython/dnsutil.py index 16549c8f6..011b722da 100644 --- a/ipapython/dnsutil.py +++ b/ipapython/dnsutil.py @@ -69,9 +69,14 @@ class DNSName(dns.name.Name): def __str__(self): return self.to_unicode() - def ToASCII(self): - #method named by RFC 3490 and python standard library - return self.to_text().decode('ascii') # must be unicode string + # method ToASCII named by RFC 3490 and python standard library + if six.PY2: + def ToASCII(self): + # must be unicode string in Py2 + return self.to_text().decode('ascii') + else: + def ToASCII(self): + return self.to_text() def canonicalize(self): return DNSName(super(DNSName, self).canonicalize()) |