From 8ab8a06bf3e26b1e9f4b1d9115840ff30cfb33ae Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Tue, 3 Mar 2020 14:56:46 +0800 Subject: [PATCH] Show warning when UnicodeEncodeError is raised --- knack/output.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/knack/output.py b/knack/output.py index 110f1e0..bbe3277 100644 --- a/knack/output.py +++ b/knack/output.py @@ -160,6 +160,8 @@ def out(self, obj, formatter=None, out_file=None): # pylint: disable=no-self-us else: raise except UnicodeEncodeError: + logger.warning("Unable to encode the output with %s encoding. Unsupported characters are discarded.", + out_file.encoding) print(output.encode('ascii', 'ignore').decode('utf-8', 'ignore'), file=out_file, end='')