Commit 3bc6be5c authored by Iustin Pop's avatar Iustin Pop
Browse files

cleanup: sanitize a default parameter

Instead of relying that the usage of the parameter is ok with mutable
default parameters, let's just make it safer..

Reviewed-by: amishchenko
parent 9728ae5d
......@@ -89,7 +89,7 @@ def _Decompress(data):
raise AssertionError("Unknown data encoding")
def _CleanDirectory(path, exclude=[]):
def _CleanDirectory(path, exclude=None):
"""Removes all regular files in a directory.
@type path: str
......@@ -97,14 +97,15 @@ def _CleanDirectory(path, exclude=[]):
@type exclude: list
@param exclude: list of files to be excluded, defaults
to the empty list
@rtype: None
if not os.path.isdir(path):
# Normalize excluded paths
exclude = [os.path.normpath(i) for i in exclude]
if exclude is None:
exclude = []
# Normalize excluded paths
exclude = [os.path.normpath(i) for i in exclude]
for rel_name in utils.ListVisibleFiles(path):
full_name = os.path.normpath(os.path.join(path, rel_name))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment