From 830d83ec385ddf9eeb541027ef09453657deed56 Mon Sep 17 00:00:00 2001 From: Caleb Connolly Date: Fri, 3 May 2024 17:18:36 +0200 Subject: [PATCH] scripts: gen_compile_commands: fix invalid escape sequence warning MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Since Python 3.12 unrecognised escape sequences trigger a SyntaxWarning. Convert the '\#' string to a raw string so the backslash is correctly used as a literal. Ported from Linux commit dae4a0171e25 ("gen_compile_commands: fix invalid escape sequence warning"). This updates the script to be in-line with Linux 6.9-rc6. Signed-off-by: Caleb Connolly Reviewed-by: João Marcos Costa --- scripts/gen_compile_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py index fec513e554..e746adddd9 100755 --- a/scripts/gen_compile_commands.py +++ b/scripts/gen_compile_commands.py @@ -172,7 +172,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)', '#') # 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.39.5