From b24787a67fd8b19b9222979a963a8f28b22153ee Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Thu, 2 Feb 2017 00:20:48 +0100 Subject: [PATCH] py3: ldapupdate: fix logging str(bytes) issue bytes as argument of str() gives unexpected result by adding prefix "b" there. Also add missing safe_option() call to logging (it will fix another str(bytes) issue) https://fedorahosted.org/freeipa/ticket/4985 Reviewed-By: Martin Babinsky --- ipaserver/install/ldapupdate.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py index bc2673b31..c6ab3e2af 100644 --- a/ipaserver/install/ldapupdate.py +++ b/ipaserver/install/ldapupdate.py @@ -119,10 +119,10 @@ def safe_output(attr, values): values = [values] try: - all(v.decode('ascii') for v in values) + values = [v.decode('ascii') for v in values] except UnicodeDecodeError: try: - values = [base64.b64encode(v) for v in values] + values = [base64.b64encode(v).decode('ascii') for v in values] except TypeError: pass @@ -656,7 +656,9 @@ class LDAPUpdate(object): try: entry_values.remove(update_value) except ValueError: - self.debug("remove: '%s' not in %s", update_value, attr) + self.debug( + "remove: '%s' not in %s", + safe_output(attr, update_value), attr) else: entry[attr] = entry_values self.debug('remove: updated value %s', safe_output(