[Kimchi-devel] [PATCH] [Wok 2/2] Issue #115: _get_resources wok_log.error result into unicode error

archus at linux.vnet.ibm.com archus at linux.vnet.ibm.com
Mon May 23 08:13:51 UTC 2016


From: Archana Singh <archus at linux.vnet.ibm.com>

As ident is in encoded value but e.message is in unicode value,
combination of which result into unicode value having encoded ident value.
So when wok_log.error try to encode(encoded value) it result into error.

This patch fix the unicode error by encoding e.message.

Signed-off-by: Archana Singh <archus at linux.vnet.ibm.com>
---
 src/wok/control/base.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/wok/control/base.py b/src/wok/control/base.py
index be5f618..d4fd4e4 100644
--- a/src/wok/control/base.py
+++ b/src/wok/control/base.py
@@ -373,9 +373,13 @@ class Collection(object):
                     res.lookup()
                 except Exception as e:
                     # In case of errors when fetching a resource info, pass and
-                    # log the error, so, other resources are returned
+                    # log the error, so, other resources are returned.
+                    # Encoding error message as ident is also encoded value.
+                    # This has to be done to avoid unicode error,
+                    # as combination of encoded and unicode value results into
+                    # unicode error.
                     wok_log.error("Problem in lookup of resource '%s'. "
-                                  "Detail: %s" % (ident, e.message))
+                                  "Detail: %s" % (ident, encode_value(e.message)))
                     continue
                 res_list.append(res)
             return res_list
-- 
1.8.3.1




More information about the Kimchi-devel mailing list