mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipalib.rpc: Send base64-encoded data as string under Python 3
Python 3's JSON library cannot deal with bytes, so decode base64-encoded data to string. Part of the work for https://fedorahosted.org/freeipa/ticket/4985 Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Petr Spacek <pspacek@redhat.com>
This commit is contained in:
parent
095d0cb7af
commit
baaa041b8a
@ -297,7 +297,10 @@ def json_encode_binary(val, version):
|
||||
new_list = [json_encode_binary(v, version) for v in val]
|
||||
return new_list
|
||||
elif isinstance(val, bytes):
|
||||
return {'__base64__': base64.b64encode(val)}
|
||||
encoded = base64.b64encode(val)
|
||||
if not six.PY2:
|
||||
encoded = encoded.decode('ascii')
|
||||
return {'__base64__': encoded}
|
||||
elif isinstance(val, Decimal):
|
||||
return {'__base64__': base64.b64encode(str(val))}
|
||||
elif isinstance(val, DN):
|
||||
|
Loading…
Reference in New Issue
Block a user