From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQk7c-0006Tt-RN for qemu-devel@nongnu.org; Fri, 12 Apr 2013 15:59:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQk7W-0007CT-OE for qemu-devel@nongnu.org; Fri, 12 Apr 2013 15:58:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQk7W-0007C9-Gw for qemu-devel@nongnu.org; Fri, 12 Apr 2013 15:58:50 -0400 From: Tomoki Sekiyama Date: Fri, 12 Apr 2013 16:02:15 -0400 Message-ID: <20130412200215.20814.548.stgit@corona> In-Reply-To: <20130412200139.20814.71718.stgit@corona> References: <20130412200139.20814.71718.stgit@corona> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [RFC PATCH v2 11/11] QMP/qmp.py: set locale for exceptions to display non-ascii messages correctly Reply-To: tomoki.sekiyama@hds.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, lcapitulino@redhat.com, vrozenfe@redhat.com, Tomoki Sekiyama , mdroth@linux.vnet.ibm.com qemu-ga in Windows might return error message with multibyte characters when the guest OS language is set to other than English. To display such messages correctly, this decodes the message based on locale settings. Signed-off-by: Tomoki Sekiyama --- QMP/qmp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/QMP/qmp.py b/QMP/qmp.py index c551df1..ee21819 100644 --- a/QMP/qmp.py +++ b/QMP/qmp.py @@ -11,6 +11,7 @@ import json import errno import socket +import locale class QMPError(Exception): pass @@ -133,7 +134,8 @@ class QEMUMonitorProtocol: def command(self, cmd, **kwds): ret = self.cmd(cmd, kwds) if ret.has_key('error'): - raise Exception(ret['error']['desc']) + enc = locale.getpreferredencoding() + raise Exception(ret['error']['desc'].encode(enc)) return ret['return'] def pull_event(self, wait=False):