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=jaben.carsey@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 655C621164C6B for ; Mon, 15 Oct 2018 10:43:16 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Oct 2018 10:43:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,385,1534834800"; d="scan'208";a="95416761" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga002.fm.intel.com with ESMTP; 15 Oct 2018 10:43:15 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.16]) by FMSMSX108.amr.corp.intel.com ([169.254.9.237]) with mapi id 14.03.0319.002; Mon, 15 Oct 2018 10:43:15 -0700 From: "Carsey, Jaben" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [edk2] [Patch] BaseTools: Add check for the string type whether is same Thread-Index: AQHUZITwxRM9BZ0qBUy/lHxT50PHjqUglAhQ Date: Mon, 15 Oct 2018 17:43:15 +0000 Message-ID: References: <1539607503-8048-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1539607503-8048-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNmQ3NDFiNGItYjk0Ny00YzcwLThjOWUtNmFkODM4ZWQ0OTgyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZFJmYzJjdUpDXC9Pa05EcWxzWlA4V29RXC84OVpuMHhnNXlramtoa3ZDeFJoTFF6bng1Qk8xWUVNMFlBQ0JhbEZNIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.1.200.107] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Add check for the string type whether is same 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: Mon, 15 Oct 2018 17:43:16 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Yonghong Zhu > Sent: Monday, October 15, 2018 5:45 AM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [edk2] [Patch] BaseTools: Add check for the string type whether = is > same >=20 > From: zhijufan >=20 > Relational and equality operators require both operands to be of > the same type. > Treat the string 'A' and "A" as same type, but for "A" and L"A" > are not same type since one is general string, another is unicode > string. >=20 > True:'A'<'B', "A"<"B" 'A'<"B", L'A' Error:'A'=20 > Cc: Liming Gao > Cc: Yonghong Zhu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Zhiju.Fan > --- > BaseTools/Source/Python/Common/Expression.py | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/Common/Expression.py > b/BaseTools/Source/Python/Common/Expression.py > index 78c69fa..84898f7 100644 > --- a/BaseTools/Source/Python/Common/Expression.py > +++ b/BaseTools/Source/Python/Common/Expression.py > @@ -295,12 +295,12 @@ class ValueExpression(BaseExpression): > # bitwise and logical operation between number and b= oolean is > allowed > pass > else: > raise BadExpression(ERR_EXPR_TYPE) > if isinstance(Oprand1, type('')) and isinstance(Oprand2, typ= e('')): > - if (Oprand1.startswith('L"') and not Oprand2.startswith(= 'L"')) or \ > - (not Oprand1.startswith('L"') and Oprand2.startswith= ('L"')): > + if ((Oprand1.startswith('L"') or Oprand1.startswith('L')= ) and (not > Oprand2.startswith('L"')) and (not Oprand2.startswith("L'"))) or \ > + (((not Oprand1.startswith('L"')) and (not > Oprand1.startswith("L'"))) and (Oprand2.startswith('L"') or > Oprand2.startswith('L'))): > raise BadExpression(ERR_STRING_CMP % (Oprand1, Opera= tor, > Oprand2)) > if 'in' in Operator and isinstance(Oprand2, type('')): > Oprand2 =3D Oprand2.split() > EvalStr =3D 'Oprand1 ' + Operator + ' Oprand2' >=20 > @@ -825,10 +825,12 @@ class ValueExpressionEx(ValueExpression): > except BadExpression as Value: > if self.PcdType in TAB_PCD_NUMERIC_TYPES: > PcdValue =3D PcdValue.strip() > if PcdValue.startswith('{') and PcdValue.endswith('}'): > PcdValue =3D SplitPcdValueString(PcdValue[1:-1]) > + if ERR_STRING_CMP.split(':')[0] in Value.message: > + raise BadExpression("Type: %s, Value: %s, %s" % (sel= f.PcdType, > PcdValue, Value)) > if isinstance(PcdValue, type([])): > TmpValue =3D 0 > Size =3D 0 > ValueType =3D '' > for Item in PcdValue: > -- > 2.6.1.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel