[PATCH 11/11] Only give Size objects a __div__ method under python2.

Chris Lumens clumens at redhat.com
Thu Apr 23 18:54:18 UTC 2015


---
 blivet/size.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/blivet/size.py b/blivet/size.py
index 29d2cb6..42e5612 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -294,8 +294,13 @@ class Size(Decimal):
         return Size(Decimal.__mul__(self, other))
     __rmul__ = __mul__
 
-    def __div__(self, other, context=None):
-        return Size(Decimal.__div__(self, other))
+    # Only python2 Decimal objects have a __div__ method.
+    if six.PY2:
+        # But pylint running under python3 still has to be told to ignore this,
+        # because it'll get through the six guard anyway.
+        # pylint: disable=no-member
+        def __div__(self, other, context=None):
+            return Size(Decimal.__div__(self, other))
 
     def __truediv__(self, other, context=None):
         return Size(Decimal.__truediv__(self, other))
-- 
2.2.2



More information about the anaconda-patches mailing list