From 563ee968797c27501d3fc216e9bc4f672ea987f4 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 28 Sep 2017 16:20:19 -0400 Subject: [PATCH] Harden confetty to weird text strings If it can't properly encode to printable, use repr instead. --- confluent_client/bin/confetty | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index 56fd039c..a8afe293 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -291,7 +291,10 @@ def print_result(res): elif type(res[key]) == list: attrstr = '%s=%s' % (key, recurse_format(res[key])) elif not isinstance(res[key], dict): - print '{0}: {1}'.format(key, res[key]) + try: + print '{0}: {1}'.format(key, res[key]) + except UnicodeEncodeError: + print '{0}: {1}'.format(key, repr(res[key])) continue elif 'value' in res[key] and res[key]['value'] is not None: attrstr = '%s="%s"' % (key, res[key]['value'])