]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Sync with commit-id: 9d529dd324d234d7aeaa3e6b4d3ab961f177e2ed
authorSalvatore Orlando <salv.orlando@gmail.com>
Fri, 17 Jan 2014 16:48:44 +0000 (08:48 -0800)
committerEugene Nikanorov <enikanorov@mirantis.com>
Sun, 2 Feb 2014 09:43:28 +0000 (13:43 +0400)
(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

index b060c417d604925bd99d8091218e9b5a052f3833..618d8fbc51568bd3d99e676c2e0492ebe5abee8d 100644 (file)
@@ -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