From 9049856afcc0a19a941a6617b391e97d30a927c4 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Fri, 17 Jan 2014 08:48:44 -0800 Subject: [PATCH] Sync with commit-id: 9d529dd324d234d7aeaa3e6b4d3ab961f177e2ed (Pulling from the gate, neutron fail rates are currently too high to have neutron jobs in the queue.) Related-Bug: #1270212 Change-Id: I94965b395cfb34ed1576b84f21aa48edf991d629 --- neutron/openstack/common/gettextutils.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/neutron/openstack/common/gettextutils.py b/neutron/openstack/common/gettextutils.py index b060c417d..618d8fbc5 100644 --- a/neutron/openstack/common/gettextutils.py +++ b/neutron/openstack/common/gettextutils.py @@ -193,10 +193,11 @@ class Message(six.text_type): # When we mod a Message we want the actual operation to be performed # by the parent class (i.e. unicode()), the only thing we do here is # save the original msgid and the parameters in case of a translation - unicode_mod = super(Message, self).__mod__(other) + params = self._sanitize_mod_params(other) + unicode_mod = super(Message, self).__mod__(params) modded = Message(self.msgid, msgtext=unicode_mod, - params=self._sanitize_mod_params(other), + params=params, domain=self.domain) return modded @@ -235,8 +236,17 @@ class Message(six.text_type): params = self._copy_param(dict_param) else: params = {} + # Save our existing parameters as defaults to protect + # ourselves from losing values if we are called through an + # (erroneous) chain that builds a valid Message with + # arguments, and then does something like "msg % kwds" + # where kwds is an empty dictionary. + src = {} + if isinstance(self.params, dict): + src.update(self.params) + src.update(dict_param) for key in keys: - params[key] = self._copy_param(dict_param[key]) + params[key] = self._copy_param(src[key]) return params -- 2.45.2