From nobody Thu Sep 19 01:23:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1720047358; cv=none; d=zohomail.com; s=zohoarc; b=Tg2sBsGhNPRmAZLZjQCdEX9TkTIivKGrnYyqaTjIX2fYeMvYAgIDRsWegy2dGezHnwkNTP4SojbyHK8Uce/RiKwHsnGUkgV89KurqeG3p7cA2uOu8oT5LO8T2nYKkDDk2Lzs9tY5uufRn/IUCiazVr4ovBSu3xDiWGAmZegdiE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720047358; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AFUGiegqbMuC9H9PbqyiLhEoErZkG5s/nrc/O3c/qqA=; b=jGyxfwBcHRheT/UGh/k/EYiJU54lyCKwfx01LTarwGjBBprjx3K/xdpfxKKlQ30e+n5asxJZgkMbXoTUuXaPBAKsok49TRD1zCFOG8Dr5iqMeLWTsQ0KoNgk2eAKWDtEkcZ/rPfBGY+pDGzH9mVPSdM/9sVpxLMPjq79774shm4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1720047358609118.40147042339981; Wed, 3 Jul 2024 15:55:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.753356.1161610 (Exim 4.92) (envelope-from ) id 1sP8t0-0004pf-B8; Wed, 03 Jul 2024 22:55:38 +0000 Received: by outflank-mailman (output) from mailman id 753356.1161610; Wed, 03 Jul 2024 22:55:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sP8t0-0004pW-7d; Wed, 03 Jul 2024 22:55:38 +0000 Received: by outflank-mailman (input) for mailman id 753356; Wed, 03 Jul 2024 22:55:37 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sP8sz-0004Kt-Mt for xen-devel@lists.xenproject.org; Wed, 03 Jul 2024 22:55:37 +0000 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [2a00:1450:4864:20::631]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5ca5a0bf-398f-11ef-bbf9-fd08da9f4363; Thu, 04 Jul 2024 00:55:37 +0200 (CEST) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a7194ce90afso1946666b.2 for ; Wed, 03 Jul 2024 15:55:37 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf638f3sm549984566b.89.2024.07.03.15.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:55:33 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5ca5a0bf-398f-11ef-bbf9-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1720047335; x=1720652135; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AFUGiegqbMuC9H9PbqyiLhEoErZkG5s/nrc/O3c/qqA=; b=OxGXtAVJ4Nv5v67J+5JiaUB/8NAldl+flItHWUuPHqRHBjrpVZDA4KGltCfcWd7oNW NJs8AAjQuXDD5BMy5OKoCPheo6W14jKvIeWWQq6g/xl13EYHaIrnliC+7zJ0ulXxQdwc 7+k+S8mlkP5ZkkNZLkWBsuQg12Mqn934cTA+I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047335; x=1720652135; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AFUGiegqbMuC9H9PbqyiLhEoErZkG5s/nrc/O3c/qqA=; b=AQmDgDnyO7CQc22kjkmO75bn8pdiqn6L/WoXqoDJPl8dRU7+mRxl83PaBsCwBi5k2i J3DE4+KCenjGK+0IS/vHUas7Y5Uu0xPrUoJP++9jdqVa3xDpLwlTvS8jzaDoMncEx7+V ziwQC0Ua7aLKPfpVL9rdcHLNGu4+I1wAYUe6pCe0HjuyJCgW7K0dwd07UdeccdVi+yXL IrQVgRLpmgcHTTI12RaMnToY/0sA5h2Z99YYQCVQQOQF6nBFcnQje2Z/ZuVnTz0oQAb2 NfttDK67NiSmJf9hw2xJM9TmQ/J6/V6xSRe0MYe3HhCA5JodFhIaDMq3vNWHLkExnlvJ S/eg== X-Gm-Message-State: AOJu0Yy+6VUpCzflH4zg9x3KQ2Qr3jNSq/z7PYrxF7rdvi5CcXvNrgDF iOcaXvsUFUD0YSwQUGEwa4SjaMtxlfB97pedlIOgGWW76oQBTL+l5x9CO3EKVCD7ROHwdIxZ0kd w X-Google-Smtp-Source: AGHT+IETyXGsHmaw2eGrnOW4zIkrlxRNxnzOyZgqrp1bog7Onu2fsOpqcWadq5jB2XvIpNO5yxp0ww== X-Received: by 2002:a17:907:31c6:b0:a72:b340:8827 with SMTP id a640c23a62f3a-a75144398c7mr1014444966b.41.1720047335609; Wed, 03 Jul 2024 15:55:35 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Anthony PERARD , Jan Beulich , Stefano Stabellini , Julien Grall , Oleksii Kurochko Subject: [PATCH 2/2] build/mkheader: Fix Syntax/DeprecationWarnings Date: Wed, 3 Jul 2024 23:55:25 +0100 Message-Id: <20240703225525.1759907-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240703225525.1759907-1-andrew.cooper3@citrix.com> References: <20240703225525.1759907-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1720047359369100003 Content-Type: text/plain; charset="utf-8" With Python 3.11, the following is emitted during a build: tools/include/xen-foreign/mkheader.py:162: DeprecationWarning: invalid es= cape sequence '\s' regex =3D "#define\s+%s\\b" % define; tools/include/xen-foreign/mkheader.py:177: DeprecationWarning: invalid es= cape sequence '\*' input =3D re.compile("/\*(.*?)\*/", re.S).sub("", input) tools/include/xen-foreign/mkheader.py:178: DeprecationWarning: invalid es= cape sequence '\s' input =3D re.compile("\n\s*\n", re.S).sub("\n", input); tools/include/xen-foreign/mkheader.py:182: DeprecationWarning: invalid es= cape sequence '\s' regex =3D "union\s+%s\s*\{(.*?)\n\};" % union; tools/include/xen-foreign/mkheader.py:192: DeprecationWarning: invalid es= cape sequence '\s' regex =3D "(?:#ifdef ([A-Z_]+))?\nstruct\s+%s\s*\{(.*?)\n\};" % struct; tools/include/xen-foreign/mkheader.py:218: DeprecationWarning: invalid es= cape sequence '\s' output =3D re.sub("\\b(union\s+%s)\\b" % union, "\\1_%s" % arch, output= ); tools/include/xen-foreign/mkheader.py:222: DeprecationWarning: invalid es= cape sequence '\s' output =3D re.sub("\\b(struct\s+%s)\\b" % struct, "\\1_%s" % arch, outp= ut); Python regexes should use raw strings. Convert all regexes, and drop escap= ed backslashes. Note that regular escape sequences are interpreted normally w= hen parsing a regex, so \n even in a raw-string regex is a newline. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Anthony PERARD --- CC: Anthony PERARD CC: Jan Beulich CC: Stefano Stabellini CC: Julien Grall CC: Oleksii Kurochko --- tools/include/xen-foreign/mkheader.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/include/xen-foreign/mkheader.py b/tools/include/xen-fore= ign/mkheader.py index 3a33df4984a2..128b0f3014c2 100644 --- a/tools/include/xen-foreign/mkheader.py +++ b/tools/include/xen-foreign/mkheader.py @@ -159,7 +159,7 @@ defined =3D {} # add defines to output for line in re.findall("#define[^\n]+", input): for define in defines: - regex =3D "#define\s+%s\\b" % define + regex =3D r"#define\s+%s\b" % define match =3D re.search(regex, line) if None =3D=3D match: continue @@ -168,18 +168,18 @@ for line in re.findall("#define[^\n]+", input): replace =3D define + "_" + arch.upper() else: replace =3D define + "_" + arch - regex =3D "\\b%s\\b" % define + regex =3D r"\b%s\b" % define output +=3D re.sub(regex, replace, line) + "\n" output +=3D "\n" =20 # delete defines, comments, empty lines input =3D re.sub("#define[^\n]+\n", "", input) -input =3D re.compile("/\*(.*?)\*/", re.S).sub("", input) -input =3D re.compile("\n\s*\n", re.S).sub("\n", input) +input =3D re.compile(r"/\*(.*?)\*/", re.S).sub("", input) +input =3D re.compile(r"\n\s*\n", re.S).sub("\n", input) =20 # add unions to output for union in unions: - regex =3D "union\s+%s\s*\{(.*?)\n\};" % union + regex =3D r"union\s+%s\s*\{(.*?)\n\};" % union match =3D re.search(regex, input, re.S) if None =3D=3D match: output +=3D "#define %s_has_no_%s 1\n" % (arch, union) @@ -189,7 +189,7 @@ for union in unions: =20 # add structs to output for struct in structs: - regex =3D "(?:#ifdef ([A-Z_]+))?\nstruct\s+%s\s*\{(.*?)\n\};" % struct + regex =3D r"(?:#ifdef ([A-Z_]+))?\nstruct\s+%s\s*\{(.*?)\n\};" % struct match =3D re.search(regex, input, re.S) if None =3D=3D match or \ (match.group(1) is not None and match.group(1) not in defined): @@ -211,20 +211,20 @@ for define in defines: replace =3D define + "_" + arch.upper() else: replace =3D define + "_" + arch - output =3D re.sub("\\b%s\\b" % define, replace, output) + output =3D re.sub(r"\b%s\b" % define, replace, output) =20 # replace: unions for union in unions: - output =3D re.sub("\\b(union\s+%s)\\b" % union, "\\1_%s" % arch, outpu= t) + output =3D re.sub(r"\b(union\s+%s)\b" % union, r"\1_%s" % arch, output) =20 # replace: structs + struct typedefs for struct in structs: - output =3D re.sub("\\b(struct\s+%s)\\b" % struct, "\\1_%s" % arch, out= put) - output =3D re.sub("\\b(%s)_t\\b" % struct, "\\1_%s_t" % arch, output) + output =3D re.sub(r"\b(struct\s+%s)\b" % struct, r"\1_%s" % arch, outp= ut) + output =3D re.sub(r"\b(%s)_t\b" % struct, r"\1_%s_t" % arch, output) =20 # replace: integer types for old, new in inttypes[arch]: - output =3D re.sub("\\b%s\\b" % old, new, output) + output =3D re.sub(r"\b%s\b" % old, new, output) =20 # print results with open(outfile, "w") as f: --=20 2.39.2