[master 8/16] Do not rely on __sub__ being implemented as __add__ (-1)*

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


From: Vratislav Podzimek <vpodzime at redhat.com>

There's no point in having two-line comment instead of 6 extra characters and
rely on something that's not a part of the API and may, and in fact did in
Python 3, change.
---
 blivet/size.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/blivet/size.py b/blivet/size.py
index 1cc17f2..a05b35f 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -282,9 +282,7 @@ def __radd__(self, other, context=None):
         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)
+        return Size(Decimal.__sub__(self, other))
 
     def __mul__(self, other, context=None):
         return Size(Decimal.__mul__(self, other))


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


More information about the anaconda-patches mailing list