Use immutable arg rather mutable arg

Passing mutable objects as default args is a known Python pitfall.
We'd better avoid this. This commit changes mutable default args with
None, then use 'arg = arg or []'.

Change-Id: I52a37bbc129fab40a99c919a837147d663941dce
This commit is contained in:
liuqing
2014-07-01 16:42:24 +08:00
parent 90abb4cfb2
commit 4766d168ba

View File

@@ -21,7 +21,9 @@ places where actual behavior differs from the spec.
from keystoneclient import access
def assert_has_keys(dict, required=[], optional=[]):
def assert_has_keys(dict, required=None, optional=None):
required = required or []
optional = optional or []
keys = dict.keys()
for k in required:
try: