From 1f8bcc23870d53653cd061abd75b57b41bc7ff1c Mon Sep 17 00:00:00 2001 From: Mike Fulbright Date: Mon, 9 Jul 2001 17:20:36 +0000 Subject: weird things happen when you remove from a list you at iterating over - rewrote to avoid this behavior --- autopart.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/autopart.py b/autopart.py index 90984f584..a1604912a 100644 --- a/autopart.py +++ b/autopart.py @@ -108,9 +108,14 @@ class partlist: return retval def reset(self): + dellist = [] for part in self.parts: + dellist.append(part) + + for part in dellist: self.parts.remove(part) del part + self.parts = [] @@ -570,10 +575,14 @@ def processPartitioning(diskset, requests, newParts): # If we created the extended partition on the same device as the logical # partition, remove it from out list, as it will be cleaned up for us # when the extended partition gets removed. + dellist = [] for part in newParts.parts: if (part.type & parted.PARTITION_LOGICAL and extendeds.has_key(part.geom.disk.dev.path)): - newParts.parts.remove(part) + dellist.append(part) + + for part in dellist: + newParts.parts.remove(part) # Finally, remove all of the partitions we added in the last try from # the disks. We'll start again from there. -- cgit