From 8e3817593886b0b07c5053c0efafd5456a6a9513 Mon Sep 17 00:00:00 2001 From: James Carey <jecarey@us.ibm.com> Date: Sun, 20 Apr 2014 20:28:15 +0000 Subject: [PATCH] Enable log messages to handle exceptions containing unicode Currently the format string is a normal string, which in py2x is not unicode. When the unicode exception information is used to replace the %s, str() is called on it, but because it is unicode str() fails. Making the format string unicode fixes this. For the error log this is done by making it translatable and for the debug message by explicity making it unicode. The exception will contain unicode when the exception being returned by the other project is either translated to a language using unicode characters or when lazy translation is enabled and a gettextutils.Message instance is returned. Change-Id: I1706f5eb9dfbee434f8882b03dad4674d955c370 Closes-Bug: #1310397 --- oslo/messaging/rpc/dispatcher.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/oslo/messaging/rpc/dispatcher.py b/oslo/messaging/rpc/dispatcher.py index b9d114f87..328ea44cf 100644 --- a/oslo/messaging/rpc/dispatcher.py +++ b/oslo/messaging/rpc/dispatcher.py @@ -32,6 +32,7 @@ import six from oslo.messaging import _utils as utils from oslo.messaging import localcontext +from oslo.messaging.openstack.common.gettextutils import _ # noqa from oslo.messaging import serializer as msg_serializer from oslo.messaging import server as msg_server from oslo.messaging import target as msg_target @@ -132,13 +133,13 @@ class RPCDispatcher(object): incoming.reply(self._dispatch(incoming.ctxt, incoming.message)) except ExpectedException as e: - LOG.debug('Expected exception during message handling (%s)' % + LOG.debug(u'Expected exception during message handling (%s)' % e.exc_info[1]) incoming.reply(failure=e.exc_info, log_failure=False) except Exception as e: # sys.exc_info() is deleted by LOG.exception(). exc_info = sys.exc_info() - LOG.error('Exception during message handling: %s', e, + LOG.error(_('Exception during message handling: %s'), e, exc_info=exc_info) incoming.reply(failure=exc_info) # NOTE(dhellmann): Remove circular object reference