ipadiscovery: Return realm as a string

We don't have a use for realm as a bytes instance, return it as a
string, otherwise there's a use of str() on bytes in py3.

https://pagure.io/freeipa/issue/4985

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Stanislav Laznicka authored and Martin Basti committed 2017-06-15 13:42:52 +02:00
1 parent e8358eaea9
commit 1cab1e980c
1 file changed
+7 -1
+7 -1
View File
@@ -531,7 +531,13 @@ class IPADiscovery(object):
for answer in answers:
root_logger.debug("DNS record found: %s", answer)
if answer.strings:
realm = answer.strings[0]
try:
realm = answer.strings[0].decode('utf-8')
except UnicodeDecodeError as e:
root_logger.debug(
'A TXT record cannot be decoded as UTF-8: {err}'
.format(err=e))
continue
if realm:
break
return realm