diff --git a/pelican/generators.py b/pelican/generators.py index ab90b25a..52ef8a4c 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -160,12 +160,12 @@ class Generator: root, topdown=True, followlinks=True): excl = exclusions_by_dirpath.get(dirpath, ()) # We copy the `dirs` list as we will modify it in the loop: - # ---- - if any(fnmatch.fnmatch(dir, willignore) for willignore in subignores): - dirs.remove(dir) - # ---- for d in list(dirs): + # ---- + if any( fnmatch.fnmatch(d, willignore) for willignore in subignores): + dirs.remove(d) + # ---- if (d in excl or any(fnmatch.fnmatch(d, ignore) for ignore in ignores)):