From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 27B7C2119A461 for ; Sun, 9 Dec 2018 05:44:21 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Dec 2018 05:44:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,334,1539673200"; d="scan'208";a="128423308" Received: from bfeng1-mobl1.ccr.corp.intel.com ([10.251.3.190]) by fmsmga001.fm.intel.com with ESMTP; 09 Dec 2018 05:44:20 -0800 From: BobCF To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao Date: Sun, 9 Dec 2018 21:44:13 +0800 Message-Id: <20181209134413.11868-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 Subject: [Patch] BaseTools: Fixed bugs in CopyDict function X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Dec 2018 13:44:22 -0000 https://bugzilla.tianocore.org/show_bug.cgi?id=1387 Remove the CopyDict incorrect usage for non-dict input data. Add a check for CopyDict input Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- BaseTools/Source/Python/Common/Misc.py | 2 ++ BaseTools/Source/Python/Workspace/DscBuildData.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index b063f064fb..6a22d01012 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -2137,10 +2137,12 @@ def PackByteFormatGUID(Guid): # # @retval new dict or orderdict # def CopyDict(ori_dict): dict_type = ori_dict.__class__ + if dict_type not in (dict,OrderedDict): + return ori_dict new_dict = dict_type() for key in ori_dict: if isinstance(ori_dict[key],(dict,OrderedDict)): new_dict[key] = CopyDict(ori_dict[key]) else: diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index b485c75a84..4543ae7dc0 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -972,11 +972,11 @@ class DscBuildData(PlatformBuildClassObject): for skuid in pcd.SkuInfoList: skuobj = pcd.SkuInfoList.get(skuid) if TAB_DEFAULT_STORES_DEFAULT not in skuobj.DefaultStoreDict: PcdDefaultStoreSet = set(defaultstorename for defaultstorename in skuobj.DefaultStoreDict) mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet) - skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename]) + skuobj.DefaultStoreDict[TAB_DEFAULT_STORES_DEFAULT] = skuobj.DefaultStoreDict[mindefaultstorename] return Pcds def RecoverCommandLinePcd(self): def UpdateCommandLineValue(pcd): if pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], @@ -2767,11 +2767,11 @@ class DscBuildData(PlatformBuildClassObject): for skuid in PcdObj.SkuInfoList: skuobj = PcdObj.SkuInfoList[skuid] mindefaultstorename = DefaultStoreObj.GetMin(set(defaultstorename for defaultstorename in skuobj.DefaultStoreDict)) for defaultstorename in DefaultStores: if defaultstorename not in skuobj.DefaultStoreDict: - skuobj.DefaultStoreDict[defaultstorename] = CopyDict(skuobj.DefaultStoreDict[mindefaultstorename]) + skuobj.DefaultStoreDict[defaultstorename] = skuobj.DefaultStoreDict[mindefaultstorename] skuobj.HiiDefaultValue = skuobj.DefaultStoreDict[mindefaultstorename] for skuname, skuid in SkuIds.items(): if skuname not in PcdObj.SkuInfoList: nextskuid = self.SkuIdMgr.GetNextSkuId(skuname) while nextskuid not in PcdObj.SkuInfoList: -- 2.18.0.windows.1