From e32f7bc96dc8db7af0c1c532e4990c9a36a12354 Mon Sep 17 00:00:00 2001 From: "Fan, ZhijuX" Date: Thu, 12 Sep 2019 16:18:27 +0800 Subject: BaseTools:change some incorrect parameter defaults BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1858 for Dict={},There are pitfalls in the way this default parameter is set and Dict is not used in functions, other functions have these two cases, I will change some incorrect parameter defaults This patch is going to fix this issue Cc: Liming Gao Cc: Bob Feng Signed-off-by: Zhiju.Fan Reviewed-by: Bob Feng --- BaseTools/Source/Python/Common/StringUtils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'BaseTools/Source/Python/Common/StringUtils.py') diff --git a/BaseTools/Source/Python/Common/StringUtils.py b/BaseTools/Source/Python/Common/StringUtils.py index 0febbc0034..73dafa797a 100644 --- a/BaseTools/Source/Python/Common/StringUtils.py +++ b/BaseTools/Source/Python/Common/StringUtils.py @@ -243,8 +243,10 @@ def SplitModuleType(Key): # # @retval NewList A new string list whose macros are replaced # -def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement=False): +def ReplaceMacros(StringList, MacroDefinitions=None, SelfReplacement=False): NewList = [] + if MacroDefinitions is None: + MacroDefinitions = {} for String in StringList: if isinstance(String, type('')): NewList.append(ReplaceMacro(String, MacroDefinitions, SelfReplacement)) @@ -264,8 +266,10 @@ def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement=False): # # @retval string The string whose macros are replaced # -def ReplaceMacro(String, MacroDefinitions={}, SelfReplacement=False, RaiseError=False): +def ReplaceMacro(String, MacroDefinitions=None, SelfReplacement=False, RaiseError=False): LastString = String + if MacroDefinitions is None: + MacroDefinitions = {} while String and MacroDefinitions: MacroUsed = GlobalData.gMacroRefPattern.findall(String) # no macro found in String, stop replacing @@ -298,7 +302,7 @@ def ReplaceMacro(String, MacroDefinitions={}, SelfReplacement=False, RaiseError= # # @retval Path Formatted path # -def NormPath(Path, Defines={}): +def NormPath(Path, Defines=None): IsRelativePath = False if Path: if Path[0] == '.': -- cgit v1.2.3