mirror of
https://github.com/clearlinux/common.git
synced 2026-04-28 11:03:48 +00:00
Don't alter a list we're iterating through
Fix a couple of places where we're trying to remove files from the files list while we're iterating through it -- replicate the change elsewhere to keep a temporary list of the files to remove, then iterate through *that* list after iterating through the global files list.
This commit is contained in:
@@ -98,9 +98,13 @@ def zap_entire_file_end(filename):
|
||||
global files
|
||||
global files_chunks
|
||||
global files_header
|
||||
files_to_remove = list()
|
||||
for file in files:
|
||||
if file.endswith(filename):
|
||||
files.remove(file)
|
||||
# Don't modify the original list while iterating over it
|
||||
files_to_remove.append(file)
|
||||
for file in files_to_remove:
|
||||
files.remove(file)
|
||||
|
||||
def zap_line_in_file_substring(filename, match):
|
||||
global header
|
||||
@@ -186,7 +190,7 @@ def zap_empty_chunks():
|
||||
files_to_remove = list()
|
||||
for file in files:
|
||||
if file not in files_chunks:
|
||||
files.remove(file)
|
||||
files_to_remove.append(file)
|
||||
continue
|
||||
to_remove = list()
|
||||
for chunk in files_chunks[file]:
|
||||
|
||||
Reference in New Issue
Block a user