From 506362400c117f49cfdc531fefab46f51b0ed4e6 Mon Sep 17 00:00:00 2001 From: Dmitry Bogun Date: Wed, 6 Aug 2014 16:25:18 +0300 Subject: [PATCH] Remove dangerous arguments default Method manila.network.linux.ip_lib.IpNetnsCommand.execute use mutable object as default value for argument addl_env. In 99% cases this lead to incorrect results and it is too difficult to track what is the source of the problem. You never should use mutable default value for function/method argument. Unless you really know what are you doing. Change-Id: Iba93e55f2ead5bfc0fd4986d49f872783cf64d99 --- manila/network/linux/ip_lib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manila/network/linux/ip_lib.py b/manila/network/linux/ip_lib.py index d1c0bada24..11e1b17c03 100644 --- a/manila/network/linux/ip_lib.py +++ b/manila/network/linux/ip_lib.py @@ -383,7 +383,10 @@ class IpNetnsCommand(IpCommandBase): def delete(self, name): self._as_root('delete', name, use_root_namespace=True) - def execute(self, cmds, addl_env={}, check_exit_code=True): + def execute(self, cmds, addl_env=None, check_exit_code=True): + if addl_env is None: + addl_env = dict() + if not self._parent.namespace: raise Exception(_('No namespace defined for parent')) else: