From b619865cb785ed1d4f7402424eb644c3e8a37ff0 Mon Sep 17 00:00:00 2001 From: Stephen Shkardoon Date: Tue, 15 Nov 2016 22:46:52 +1300 Subject: [PATCH] Prevent "dictionary changed size during iteration" error In Python 3, this will return a generator. When the subsequent code modifies the list being operated on, it will trigger a RuntimeError. By using `list()` we force a copy of the list to be made. --- lvcache/lvm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lvcache/lvm.py b/lvcache/lvm.py index 5613d58..ddfdc4f 100644 --- a/lvcache/lvm.py +++ b/lvcache/lvm.py @@ -93,7 +93,7 @@ def cache_status(self): status = dict(zip(cache_status_fields, status.strip().split()[:len(cache_status_fields)])) - for k in status.keys(): + for k in list(status.keys()): if status[k].isdigit(): status[k] = int(status[k]) elif '/' in status[k]: