[PATCH 1/3] Allow creating Size instance from another Size instance

Vratislav Podzimek vpodzime at redhat.com
Wed Mar 19 14:24:30 UTC 2014


Attempt to create Size instance from another Size instance should work and
result in creation of a copy.

Related: rhbz#1077179
---
 blivet/size.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/blivet/size.py b/blivet/size.py
index 74198cc..61dae94 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -196,6 +196,8 @@ class Size(Decimal):
         if bytes is not None:
             if isinstance(bytes, (int, long, float, Decimal)):
                 value = Decimal(bytes)
+            elif isinstance(bytes, Size):
+                value = Decimal(bytes.convertTo("b"))
             else:
                 raise ValueError("invalid value for bytes param")
         elif spec:
-- 
1.8.5.3



More information about the anaconda-patches mailing list