From 1cab1e980c7cad65943e2984158a458a6472c9d2 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka Date: Jun 15 2017 11:42:52 +0000 Subject: 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 --- diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py index c929a35..bff79b0 100644 --- a/ipaclient/install/ipadiscovery.py +++ b/ipaclient/install/ipadiscovery.py @@ -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