From 3bc6be5c230385087246280a6692c2bce38026f8 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Sun, 14 Dec 2008 12:02:18 +0000
Subject: [PATCH] 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
---
 lib/backend.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index dd4788a78..d7871d1c4 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -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):
     return
-
-  # Normalize excluded paths
-  exclude = [os.path.normpath(i) for i in exclude]
+  if exclude is None:
+    exclude = []
+  else:
+    # 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))
-- 
GitLab