[Kimchi-devel] [PATCH V2] Issue #333: do not encode error.html when the cherrpy version less than '3.2.5'

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Mon Mar 3 10:43:53 UTC 2014


From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

cherrypy does not encode the return of get_error_page from changeset 3591:35064e17ea5d.

The 3591:35064e17ea5d is lower than 3.2.5 version (changeset 3677:052f32b1d563).
And it is higher than 3.2.4 version (changeset 3497:cd8acbc5f2b3).

issue:
https://github.com/kimchi-project/kimchi/issues/333

Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
 src/kimchi/root.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/kimchi/root.py b/src/kimchi/root.py
index 3956ea6..5bad9b4 100644
--- a/src/kimchi/root.py
+++ b/src/kimchi/root.py
@@ -22,6 +22,7 @@ import json
 import os
 
 
+from distutils.version import LooseVersion
 from kimchi import auth
 from kimchi import template
 from kimchi.i18n import messages
@@ -49,7 +50,8 @@ class Root(Resource):
     def error_production_handler(self, status, message, traceback, version):
         data = {'code': status, 'reason': message}
         res = template.render('error.html', data)
-        if type(res) is unicode:
+        if (type(res) is unicode and
+           LooseVersion(cherrypy.__version__) < LooseVersion('3.2.5')):
             res = res.encode("utf-8")
         return res
 
@@ -57,7 +59,8 @@ class Root(Resource):
         data = {'code': status, 'reason': message,
                 'call_stack': cherrypy._cperror.format_exc()}
         res = template.render('error.html', data)
-        if type(res) is unicode:
+        if (type(res) is unicode and
+           LooseVersion(cherrypy.__version__) < LooseVersion('3.2.5')):
             res = res.encode("utf-8")
         return res
 
-- 
1.8.4.2




More information about the Kimchi-devel mailing list