From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Fri, 12 Jul 2019 14:03:25 -0700 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0DBB308222F; Fri, 12 Jul 2019 21:03:24 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id A738060BFB; Fri, 12 Jul 2019 21:03:23 +0000 (UTC) Subject: Re: [PATCH] BaseTools: Fix python3.8 SyntaxWarning To: Cole Robinson , devel@edk2.groups.io References: <6692fad1d6b57307a5da195986ed23074021fc88.1562952568.git.crobinso@redhat.com> Cc: Bob Feng , Liming Gao From: "Laszlo Ersek" Message-ID: <1425e3e8-a476-49c1-7692-61445caf7c3c@redhat.com> Date: Fri, 12 Jul 2019 23:03:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <6692fad1d6b57307a5da195986ed23074021fc88.1562952568.git.crobinso@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 12 Jul 2019 21:03:24 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 07/12/19 19:29, Cole Robinson wrote: > Building with python3.8 shows a warning like: > > SyntaxWarning: invalid escape sequence \( > GuidName = re.compile("\(GUID=[-a-fA-F0-9]+") > > It seems harmless, but it's easy enough to fix: mark the string as > raw with the 'r' prefix like is used elsewhere in the file I think the intent is to escape the opening paren '(' so that it lose its special regex meaning. Is that correct? And, the issue is that the backslash, meant for escaping the paren, in effect introduces a *string literal* escape sequence. Is that correct? If so, would it be correct to replace '\(' with '\\('? (IOW, use the string literal escape sequence \\ to encode a raw \, and then let the raw \ escape the ( on the regex level.) Anyway, after reading up a bit on raw string literals, the patch appears to do the same, only more readably. :) Reviewed-by: Laszlo Ersek (CC'ing BaseTools maintainers Bob and Liming.) Thanks! Laszlo > > Signed-off-by: Cole Robinson > --- > BaseTools/Source/Python/build/build.py | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py > index 8c3315619a..d6006b651f 100644 > --- a/BaseTools/Source/Python/build/build.py > +++ b/BaseTools/Source/Python/build/build.py > @@ -1499,7 +1499,7 @@ class Build(): > if self.Fdf: > # First get the XIP base address for FV map file. > GuidPattern = re.compile("[-a-fA-F0-9]+") > - GuidName = re.compile("\(GUID=[-a-fA-F0-9]+") > + GuidName = re.compile(r"\(GUID=[-a-fA-F0-9]+") > for FvName in Wa.FdfProfile.FvDict: > FvMapBuffer = os.path.join(Wa.FvDir, FvName + '.Fv.map') > if not os.path.exists(FvMapBuffer): >