[PATCH 03/11] Make a copy of the original format instead of just storing another ref.

David Lehman dlehman at redhat.com
Tue Sep 25 20:33:28 UTC 2012


Changed attributes of device.format should not also be reflected in
device.originalFormat. That's the whole point of saving the original.
---
 pyanaconda/storage/devices.py    |    4 ++--
 pyanaconda/storage/devicetree.py |    3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index aaf4763..00285a7 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -484,7 +484,7 @@ class StorageDevice(Device):
         self.controllable = not flags.testing
 
         self.format = format
-        self.originalFormat = self.format
+        self.originalFormat = copy.copy(self.format)
         self.fstabComment = ""
         self._targetSize = self._size
 
@@ -3935,7 +3935,7 @@ class BTRFSVolumeDevice(BTRFSDevice):
                                     label=label,
                                     volUUID=self.uuid,
                                     device=self.path)
-            self.originalFormat = self.format
+            self.originalFormat = copy.copy(self.format)
 
         label = getattr(self.format, "label", None)
         if label:
diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py
index b622a71..e6a3daa 100644
--- a/pyanaconda/storage/devicetree.py
+++ b/pyanaconda/storage/devicetree.py
@@ -26,6 +26,7 @@ import block
 import re
 import shutil
 import pprint
+import copy
 
 from errors import *
 from devices import *
@@ -1089,7 +1090,7 @@ class DeviceTree(object):
         log.info("got device: %r" % device)
         if device.format.type:
             log.info("got format: %r" % device.format)
-        device.originalFormat = device.format
+        device.originalFormat = copy.copy(device.format)
 
     def handleUdevDiskLabelFormat(self, info, device):
         disklabel_type = info.get("ID_PART_TABLE_TYPE")
-- 
1.7.7.6



More information about the anaconda-patches mailing list