chiark / gitweb /
make-secnet-sites: Apply list() to keys in delempty
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 24 Oct 2019 16:18:37 +0000 (17:18 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 24 Oct 2019 18:16:16 +0000 (19:16 +0100)
It is not permitted (in Python3) to modify a dictionary like this,
while iterating over keys().  We have to make a list of the keys,
copying them.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
make-secnet-sites

index 76d74f1a6907944b1cb5b3b2d5e2be31e1c54fae..1cc979b57e4c5c7ecb66ffcbee9edf19154541cd 100755 (executable)
@@ -527,7 +527,7 @@ def live(n):
        return 0
 def delempty(n):
        "Delete nodes that have no leafnode children"
-       for i in n.children.keys():
+       for i in list(n.children.keys()):
                delempty(n.children[i])
                if not live(n.children[i]):
                        del n.children[i]