[master 1/2] Pickling support for Size.

vojtechtrefny installerbot-noreply at redhat.com
Thu Apr 9 07:54:52 UTC 2015


From: Vojtech Trefny <vtrefny at redhat.com>

Signed-off-by: Vojtech Trefny <vtrefny at redhat.com>
---
 blivet/size.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/blivet/size.py b/blivet/size.py
index 1300ce7..317d39f 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -269,6 +269,11 @@ def __repr__(self):
     def __deepcopy__(self, memo):
         return Size(self.convertTo())
 
+    # pickling support for Size
+    # see https://docs.python.org/3/library/pickle.html#object.__reduce__
+    def __reduce__(self):
+        return (self.__class__, (self.convertTo(),))
+
     def __add__(self, other, context=None):
         return Size(Decimal.__add__(self, other, context=context))
 


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


More information about the anaconda-patches mailing list