Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1625602rdb; Mon, 2 Oct 2023 16:07:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpH/wp5Q41dqPmiQxUOHrNipm02oqBA1PJHmWupIwHZ1zj4dV2qKFk1jHjwziL/JSwT8DU X-Received: by 2002:a05:6a20:3d8a:b0:137:74f8:62ee with SMTP id s10-20020a056a203d8a00b0013774f862eemr16019476pzi.18.1696288037327; Mon, 02 Oct 2023 16:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696288037; cv=none; d=google.com; s=arc-20160816; b=V9hJ0kbF+H1pi9uHjfCug0KaA2kYQvw9qS7fS1MVu2k4epKujotVkX68cWBlrWCuji jrY4rCNSTSddWiLXZpP7EtdYyR/bJQY8j1izUwy5O4rUKz/ZcqxI0sGeXWGH7/vphMf1 WC1wHCTX0+WcUW8muxhgH3zJmndzzMSTw5B9iLeL+bJFmgtIJUUWWSRz/BehBD5TyL2e wzj1GH0Q/2/lvpQyeUIA1UdG2FO3BOvFEIB3oIYySj0+iIn44UDkF2d9HvopnbM6c8C2 94kXXZbIab/T8bsf1KBt4hylYDhekK/31fNNlwl1NL3lpCD+/P1y5/OnWkay3HNJ0iet 340A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=czrBgKLy1K869dFqcu4csd4iC6d//Z9mJHuQxd+J/NU=; fh=/GTKkbEy4UmCPC378j59SMGRdA46j2p0GtWrZK/4KmY=; b=rezoxvKscOWptkKpYrpl6zad/NkM9d4oDtz+UH5BNfM4TQ6uYhYyQHCN4/+RxUMQ29 EgMVWn9j+wD4FDhFYm1aWDUwzX/iZ0ZtVcA0vcDwDuVXhn0cSI1SbuZCNIdUOIDJAP58 qwJSf677nMi0A2Dd5KbLbIjjoNwXQYjZ4n6bdmhTn7Ji1cZ5UH89rK/K7kyc9IdcZQet EC50nzpOumuDpMvadkYW3DMN+jX7uNACsbr0Xb7Ao80E7pGabFico3kEZhcbpvRHndGb NM0dbh7HHeV8fvPa47USQnO0V1J7WgcoFWth1z3JSVOnKsvplUMiVsJRtDEnvOrm+BWi W+tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jjdz6eix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l13-20020a170902f68d00b001c76a2ebda0si4383914plg.502.2023.10.02.16.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 16:07:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jjdz6eix; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 14D06805ECD8; Mon, 2 Oct 2023 16:07:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236285AbjJBXHQ (ORCPT + 99 others); Mon, 2 Oct 2023 19:07:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbjJBXHP (ORCPT ); Mon, 2 Oct 2023 19:07:15 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63B61AD; Mon, 2 Oct 2023 16:07:12 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 820AAC433C7; Mon, 2 Oct 2023 23:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696288032; bh=pqvohkmy+2m5Tqt1sTRxlBrIprA83sMhWjYw54JI05M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Jjdz6eixvqAz08YRMbWSuL4jQlaSOX95kn5uuK4Mkq6zj1pdxcmCPphMyrBYhuByE 9n+mae1GFj78m6OwJyEKUcC5/wYYIK7LsF9xWbNpWvZaXyMyeVbJQuH9W8vLjh5RLA y/0H7xXbdRS98XpnP2zQDhGKT1lhZ+t8OvGHkfJeLkqNAW03dfnsUpSUaMtqN+7e9r /57qKywpv3q0rZndFV8DU8v7d85ynQ0UC/4zm/+SQ11mKiY1UzaDWKHgnq0oiQXzh/ L8aERvYjHrcY5hqyGdNdR9dbP1X+VszD2VL3U90PlTYSA6D87BeBHSWNSfmkGHvzB6 g52qkjS/mwXwA== Date: Mon, 2 Oct 2023 16:07:09 -0700 From: Nathan Chancellor To: Jeremy Cline Cc: Nick Desaulniers , Tom Rix , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Masahiro Yamada , linux-kbuild@vger.kernel.org Subject: Re: [PATCH] gen_compile_commands: use raw string when replacing \# Message-ID: <20231002230709.GA1029006@dev-arch.thelio-3990X> References: <20230929190446.113168-1-jeremy@jcline.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230929190446.113168-1-jeremy@jcline.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 16:07:16 -0700 (PDT) Hi Jeremy, On Fri, Sep 29, 2023 at 03:04:46PM -0400, Jeremy Cline wrote: > I noticed this since I'm running Python 3.12-rc3, which emits > "SyntaxWarning: invalid escape sequence '\#'" when running this script. > According to the Python 3.12 release notes this will eventually become a > SyntaxError. > > Based on the comment in the code, I believe the intention was to match > the literal string "\#". Marking it as a raw string will stop Python > from trying to treat it as an escape sequence and behave as intended. > > Signed-off-by: Jeremy Cline Thanks for the patch, it looks good to me. Reviewed-by: Nathan Chancellor Just a heads up, you are not the first person to see this and send a patch: https://lore.kernel.org/20230912060801.95533-5-bgray@linux.ibm.com/ But as far as I can tell, there is no movement on that changeset, so if Masahiro is able to pick this up, that would still be good. Masahiro, the original change is available at https://lore.kernel.org/all/20230929190446.113168-1-jeremy@jcline.org/, if you are able to apply it that way. > --- > scripts/clang-tools/gen_compile_commands.py | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/clang-tools/gen_compile_commands.py b/scripts/clang-tools/gen_compile_commands.py > index a84cc5737c2c..bc005cac1944 100755 > --- a/scripts/clang-tools/gen_compile_commands.py > +++ b/scripts/clang-tools/gen_compile_commands.py > @@ -170,7 +170,7 @@ def process_line(root_directory, command_prefix, file_path): > # escape the pound sign '#', either as '\#' or '$(pound)' (depending on the > # kernel version). The compile_commands.json file is not interepreted > # by Make, so this code replaces the escaped version with '#'. > - prefix = command_prefix.replace('\#', '#').replace('$(pound)', '#') > + prefix = command_prefix.replace(r'\#', '#').replace('$(pound)', '#') > > # Use os.path.abspath() to normalize the path resolving '.' and '..' . > abs_path = os.path.abspath(os.path.join(root_directory, file_path)) > -- > 2.41.0 >