All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Andrew Ballance <andrewjballance@gmail.com>
Cc: linux-kernel@vger.kernel.org, nathan@kernel.org,
	nicolas@fjasle.eu,  ndesaulniers@google.com, morbo@google.com,
	justinstitt@google.com,  linux-kbuild@vger.kernel.org,
	llvm@lists.linux.dev, skhan@linuxfoundation.org,
	 linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [PATCH] gen_compile_commands: fix invalid escape sequence
Date: Tue, 13 Feb 2024 10:48:38 +0900	[thread overview]
Message-ID: <CAK7LNARaW1V5X79BFW5_YTKY+n+OSp+_ACpRxpiw+VOJ+2hf=g@mail.gmail.com> (raw)
In-Reply-To: <20240213012035.750928-1-andrewjballance@gmail.com>

On Tue, Feb 13, 2024 at 10:21 AM Andrew Ballance
<andrewjballance@gmail.com> wrote:
>
> this fixes the error, "SyntaxWarning: invalid escape sequence '\#'"
>
> the error can be recreated by running


Not an error.
It is a warning.


>     make CC=clang compile_commands.json



What is more important is to mention the Python version
in the commit description.

Example:

---------------->8----------------
With Python 3.12, '\#' results in this warning:

  SyntaxWarning: invalid escape sequence '\#'
---------------->8----------------



Please update the commit message.




The make command is not so important.

I quickly confirm it in the interactive mode
instead of running the build command.



$ python3.12
Python 3.12.0 (main, Oct  4 2023, 06:27:34) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> '\#'
<stdin>:1: SyntaxWarning: invalid escape sequence '\#'
'\\#'
>>> '\\#'
'\\#'





>
> Signed-off-by: Andrew Ballance <andrewjballance@gmail.com>
> ---
>  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 5dea4479240b..93f64095fda9 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('\\#', '#').replace('$(pound)', '#')
>
>      # Return the canonical path, eliminating any symbolic links encountered in the path.
>      abs_path = os.path.realpath(os.path.join(root_directory, file_path))
> --
> 2.43.0
>


-- 
Best Regards
Masahiro Yamada

  reply	other threads:[~2024-02-13  1:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13  1:20 [PATCH] gen_compile_commands: fix invalid escape sequence Andrew Ballance
2024-02-13  1:48 ` Masahiro Yamada [this message]
2024-02-13  2:25   ` [PATCH v2] gen_compile_commands: fix invalid escape sequence warning Andrew Ballance
2024-02-13 20:00     ` Nicolas Schier
2024-02-14  0:31       ` Justin Stitt
2024-02-14  1:23         ` [PATCH v3 0/1] " Andrew Ballance
2024-02-14  1:23           ` [PATCH v3 1/1] " Andrew Ballance
2024-02-14 18:28             ` Justin Stitt
2024-02-14 21:27             ` Masahiro Yamada
2024-02-14  0:40     ` [PATCH v2] " Justin Stitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK7LNARaW1V5X79BFW5_YTKY+n+OSp+_ACpRxpiw+VOJ+2hf=g@mail.gmail.com' \
    --to=masahiroy@kernel.org \
    --cc=andrewjballance@gmail.com \
    --cc=justinstitt@google.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.