[Kimchi-devel] [PATCH] bug fix: encode the args in KimchiException when is is unicode.
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Wed Mar 12 14:21:55 UTC 2014
From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
I create a pool with name "kīмсhīPool"
When libvirt errors with this pool, it will cause the UnicodeDecodeError.
File "/home/shhfeng/work/workdir/kimchi/src/kimchi/model/storagepools.py",
line 401, in delete
{'name': name, 'err': e.get_error_message()})
File "/home/shhfeng/work/workdir/kimchi/src/kimchi/exception.py", line
37, in __init__
msg = _messages.get(code, code) % args
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 49:
ordinal not in range(128)
Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
src/kimchi/exception.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/kimchi/exception.py b/src/kimchi/exception.py
index 74134be..87982ea 100644
--- a/src/kimchi/exception.py
+++ b/src/kimchi/exception.py
@@ -32,6 +32,9 @@ class KimchiException(Exception):
if cherrypy.request.app:
msg = self._get_translation(args)
else:
+ for key, value in args.iteritems():
+ if isinstance(value, unicode):
+ args[key] = value.encode('utf-8')
msg = _messages.get(code, code) % args
pattern = "%s: %s" % (code, msg)
--
1.8.4.2
More information about the Kimchi-devel
mailing list