From 741f721fb76c70d92c8a53ea26323307a5b9ed3e Mon Sep 17 00:00:00 2001 From: JF Ding Date: Sun, 24 Jun 2012 07:43:15 -0700 Subject: [PATCH] encode unicode string from system w/ widechar locale else in this like system, msger will abort with string encoding/decoding errors. --- mic/msger.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mic/msger.py b/mic/msger.py index 8413f64..33f4298 100644 --- a/mic/msger.py +++ b/mic/msger.py @@ -71,6 +71,10 @@ def _general_print(head, color, msg = None, stream = None, level = 'normal'): # skip return + # encode raw 'unicode' str to utf8 encoded str + if msg and isinstance(msg, unicode): + msg = msg.encode('utf-8', 'ignore') + errormsg = '' if CATCHERR_BUFFILE_FD > 0: size = os.lseek(CATCHERR_BUFFILE_FD , 0, os.SEEK_END) -- 2.7.4