[master 14/15] Do not modify dict while iterating over its values

vpodzime installerbot-noreply at redhat.com
Thu Apr 2 14:15:19 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

Python 3 is not enough benevolent to do something like that and raises an
exception, in Python 2 it's just a bad idea.
---
 blivet/blivet.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/blivet/blivet.py b/blivet/blivet.py
index b75a193..7a73f8f 100644
--- a/blivet/blivet.py
+++ b/blivet/blivet.py
@@ -1685,6 +1685,7 @@ def copy(self):
             root.swaps = [s for s in root.swaps if s]
 
             for (mountpoint, old_dev) in root.mounts.items():
+                removed = set()
                 if old_dev is None:
                     continue
 
@@ -1692,10 +1693,13 @@ def copy(self):
                 if new_dev is None:
                     # if the device has been removed don't include this
                     # mountpoint at all
-                    del root.mounts[mountpoint]
+                    removed.add(mountpoint)
                 else:
                     root.mounts[mountpoint] = new_dev
 
+            for mnt in removed:
+                del root.mounts[mnt]
+
         log.debug("finished Blivet copy")
         return new
 


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


More information about the anaconda-patches mailing list