[master 3/3] Make roundToNearest() slightly more robust.
mulkieran
installerbot-noreply at redhat.com
Tue Jun 16 13:55:22 UTC 2015
From: mulhern <amulhern at redhat.com>
Related: #56
Check all values as Decimal values rather than checking for 0 as Size().
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/size.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/blivet/size.py b/blivet/size.py
index 4904558..0e05415 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -438,12 +438,11 @@ def roundToNearest(self, unit, rounding=ROUND_DEFAULT):
if rounding not in (ROUND_UP, ROUND_DOWN, ROUND_DEFAULT):
raise ValueError("invalid rounding specifier")
- factor = getattr(unit, "factor", unit)
+ factor = Decimal(getattr(unit, "factor", unit))
- if factor == Size(0):
+ if factor == 0:
return Size(0)
- factor = Decimal(factor)
if factor < 0:
raise ValueError("invalid rounding unit: %s" % factor)
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/5f8678b86b1bb0e8781af11e90f5c55d4f357a59
More information about the anaconda-patches
mailing list