Skip to content

Commit 9510dad

Browse files
committed
Use Decimal for Device.getSize() operations, return a float (#1801355)
1 parent 80f1a5c commit 9510dad

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/parted/device.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ def getSize(self, unit="MB"):
298298
raise SyntaxError("invalid unit %s given" % (unit))
299299

300300
size = Decimal(self.__device.length)
301-
size /= math.pow(1024.0, parted._exponent[lunit])
302-
size *= self.sectorSize
301+
size /= Decimal(math.pow(1024.0, parted._exponent[lunit]))
302+
size *= Decimal(self.sectorSize)
303303

304-
return size
304+
return float(size)
305305

306306
@localeC
307307
def getLength(self, unit='sectors'):

0 commit comments

Comments
 (0)