[master 5/16] Do not pass context to Decimal numeric operations

M4rtinK installerbot-noreply at redhat.com
Fri Apr 10 13:38:11 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

In Python 3 this causes an exception. We don't set it explicitly anywhere and
the usage of Decimal we have in our code neither does it.
---
 blivet/size.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/blivet/size.py b/blivet/size.py
index d2c39e3..9825958 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -255,7 +255,7 @@ def __new__(cls, value=0, context=None):
 
         # drop any partial byte
         size = size.to_integral_value(rounding=ROUND_DOWN)
-        self = Decimal.__new__(cls, value=size)
+        self = Decimal.__new__(cls, value=size, context=context)
         return self
 
     # Force str and unicode types since the translated sizespec may be unicode
@@ -275,26 +275,26 @@ def __deepcopy__(self, memo):
         return Size(self.convertTo())
 
     def __add__(self, other, context=None):
-        return Size(Decimal.__add__(self, other, context=context))
+        return Size(Decimal.__add__(self, other))
 
     # needed to make sum() work with Size arguments
     def __radd__(self, other, context=None):
-        return Size(Decimal.__radd__(self, other, context=context))
+        return Size(Decimal.__radd__(self, other))
 
     def __sub__(self, other, context=None):
         # subtraction is implemented using __add__ and negation, so we'll
         # be getting passed a Size
-        return Decimal.__sub__(self, other, context=context)
+        return Decimal.__sub__(self, other)
 
     def __mul__(self, other, context=None):
-        return Size(Decimal.__mul__(self, other, context=context))
+        return Size(Decimal.__mul__(self, other))
     __rmul__ = __mul__
 
     def __div__(self, other, context=None):
-        return Size(Decimal.__div__(self, other, context=context))
+        return Size(Decimal.__div__(self, other))
 
     def __mod__(self, other, context=None):
-        return Size(Decimal.__mod__(self, other, context=context))
+        return Size(Decimal.__mod__(self, other))
 
     def convertTo(self, spec=None):
         """ Return the size in the units indicated by the specifier.


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/e40d93bec748cefbd7ee6193e0893b989b8b3e78


More information about the anaconda-patches mailing list