mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
python dbcheck: don't use mutable default args
In this code def f(a, b=[]): b.append(a) return b all single argument calls to f() will affect the same copy of b. In the controls case, controls=None has the same effect as controls=[]. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
This commit is contained in:
parent
28826ec49c
commit
f17a77af46
@ -226,7 +226,8 @@ class dbcheck(object):
|
||||
raise
|
||||
pass
|
||||
|
||||
def check_database(self, DN=None, scope=ldb.SCOPE_SUBTREE, controls=[], attrs=['*']):
|
||||
def check_database(self, DN=None, scope=ldb.SCOPE_SUBTREE, controls=None,
|
||||
attrs=None):
|
||||
'''perform a database check, returning the number of errors found'''
|
||||
res = self.samdb.search(base=DN, scope=scope, attrs=['dn'], controls=controls)
|
||||
self.report('Checking %u objects' % len(res))
|
||||
@ -2021,14 +2022,15 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
|
||||
|
||||
raise KeyError
|
||||
|
||||
def check_object(self, dn, attrs=['*']):
|
||||
def check_object(self, dn, attrs=None):
|
||||
'''check one object'''
|
||||
if self.verbose:
|
||||
self.report("Checking object %s" % dn)
|
||||
|
||||
# If we modify the pass-by-reference attrs variable, then we get a
|
||||
# replPropertyMetadata for every object that we check.
|
||||
attrs = list(attrs)
|
||||
if attrs is None:
|
||||
attrs = ['*']
|
||||
else:
|
||||
# make a local copy to modify
|
||||
attrs = list(attrs)
|
||||
if "dn" in map(str.lower, attrs):
|
||||
attrs.append("name")
|
||||
if "distinguishedname" in map(str.lower, attrs):
|
||||
|
Loading…
x
Reference in New Issue
Block a user