[PATCHrhel6 master] Use Decimal instead of float for label calculations (#604639)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



NOTE: I missed 2 uses places where mixed float and Decimal were used. I 
reproduced the problem and confirmed the fix works.


You cannot multiply Decimal and float. Convert to Decimal first
for the label calculations. The %.0f conversion handles the
Decimal type the same as float, rounding to the nearest integer.

Resolves: rhbz#604639
---
 iw/partition_gui.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index 37ea043..4ccac2c 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -443,7 +443,7 @@ class DiskStripeGraph(StripeGraph):
             sel_col = self.part_type_colors["sel_freespace"]
             xoffset = last_logical_offset
             xlength = last_extended_offset - last_logical_offset
-            slcstr = "%s\n%.0f MB" % (_("Free"), float(drive.size * xlength))
+            slcstr = "%s\n%.0f MB" % (_("Free"), Decimal(str(drive.size)) * xlength)
 
             slice = Slice(stripe, slcstr, stype, xoffset, xlength,
                     dcCB = self.dcCB, cCB = self.cCB, sel_col=sel_col,
@@ -510,7 +510,7 @@ class LVMStripeGraph(StripeGraph):
             xlength = Decimal(1 - curr_offset)
 
             # with the xlength we give an approximate size
-            freestr = "%s\n%.0f MB" % (_("Free"), float(vg.size*xlength))
+            freestr = "%s\n%.0f MB" % (_("Free"), Decimal(str(vg.size)) * xlength)
 
             # We append no object.
             slice = Slice(stripe, freestr, stype, xoffset, xlength,
-- 
1.7.0.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux