[blivet:master 02/14] Change param default [] to None and convert in method
Vratislav Podzimek
vpodzime at redhat.com
Mon Mar 31 09:10:45 UTC 2014
On Fri, 2014-03-28 at 18:50 -0400, mulhern wrote:
> A default of [] (or any mutable structure) is considered dangerous because the
> default argument is packed up with the function at its definition. Thus, the
> same object is shared among all execution instances of the function that
> are called with the default argument.
>
> Signed-off-by: mulhern <amulhern at redhat.com>
> ---
> blivet/devicelibs/lvm.py | 5 ++++-
> blivet/devicelibs/mdraid.py | 7 +++++--
> scripts/makeupdates | 4 +++-
> 3 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/blivet/devicelibs/lvm.py b/blivet/devicelibs/lvm.py
> index bc6d563..c073022 100644
> --- a/blivet/devicelibs/lvm.py
> +++ b/blivet/devicelibs/lvm.py
> @@ -454,7 +454,10 @@ def lvorigin(vg_name, lv_name):
>
> return origin
>
> -def lvcreate(vg_name, lv_name, size, pvs=[]):
> +def lvcreate(vg_name, lv_name, size, pvs=None):
> + if pvs is None:
> + pvs = []
I'd suggest changing these to 'param = param or []' instead of ifs.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list