]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gen_compile_commands: fix invalid escape sequence warning
authorAndrew Ballance <andrewjballance@gmail.com>
Wed, 14 Feb 2024 01:23:05 +0000 (19:23 -0600)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 14 Feb 2024 21:57:19 +0000 (06:57 +0900)
With python 3.12, '\#' results in this warning
    SyntaxWarning: invalid escape sequence '\#'

Signed-off-by: Andrew Ballance <andrewjballance@gmail.com>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/clang-tools/gen_compile_commands.py

index 5dea4479240bc02226828f13f3fec2dc3acf36c6..e4fb686dfaa9f0ee49fadb43c6e4404fcd5ac8f3 100755 (executable)
@@ -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)', '#')
 
     # Return the canonical path, eliminating any symbolic links encountered in the path.
     abs_path = os.path.realpath(os.path.join(root_directory, file_path))