mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-24 22:27:41 -05:00
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>
This commit is contained in:
1 parent
8689e6be51
commit
28b0bfaefe
1 file changed
+3
-1
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user