summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2016-04-26 14:59:35 +0200
committerMartin Basti <mbasti@redhat.com>2016-04-28 16:22:07 +0200
commit28b0bfaefea02fe188b57b602396f5ef62863726 (patch)
treec4af3aed75fcef3f011c75c0aafe4f628ca33ed5 /ipalib
parent8689e6be515aaf5b3d6c891e9e450b99cd8af8d4 (diff)
downloadfreeipa-28b0bfaefea02fe188b57b602396f5ef62863726.tar.gz
freeipa-28b0bfaefea02fe188b57b602396f5ef62863726.tar.xz
freeipa-28b0bfaefea02fe188b57b602396f5ef62863726.zip
dns plugin: Fix zone normalization under Python 3
In Python 3, str.encode('ascii') converts to bytes, and str() (nicknamed unicode() in IPA) returns the string representation of an object, which is b'...' for bytes. So, unicode('...'.encode('ascii')) results in "b'...'". Change the code to only call encode() for the error. Part of the work for https://fedorahosted.org/freeipa/ticket/4985 Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/dns.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index b01ac840f..079cb6d98 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -1755,9 +1755,11 @@ def _normalize_zone(zone):
if isinstance(zone, unicode):
# normalize only non-IDNA zones
try:
- return unicode(zone.encode('ascii')).lower()
+ zone.encode('ascii')
except UnicodeError:
pass
+ else:
+ return zone.lower()
return zone