From 5dbb0f6fec59defd795dd501b67740a79616e86b Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: May 10 2016 10:41:15 +0000 Subject: ipalib.cli: Improve reporting of binary values in the CLI Make sure the base64-encoded value is a string, so it is printed without the b'' markers. Part of the work for: https://fedorahosted.org/freeipa/ticket/4985 Reviewed-By: Martin Basti --- diff --git a/ipalib/cli.py b/ipalib/cli.py index 3592d3b..3692e4e 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -164,10 +164,11 @@ class textui(backend.Backend): def encode_binary(self, value): """ Convert a binary value to base64. We know a value is binary - if it is a python str type, otherwise it is a plain string. + if it is a python bytes type, otherwise it is a plain string. + This function also converts datetime and DNSName values to string. """ if type(value) is bytes: - return base64.b64encode(value) + return base64.b64encode(value).decode('ascii') elif type(value) is datetime.datetime: return value.strftime(LDAP_GENERALIZED_TIME_FORMAT) elif isinstance(value, DNSName):