From c73a397a418b1d5935dcc4233e651cf1773a57ca Mon Sep 17 00:00:00 2001 From: Old-Ding <35417409+Old-Ding@users.noreply.github.com> Date: Fri, 10 Jul 2026 06:08:00 +0800 Subject: [PATCH] CBMC: Escape Python regex strings (#1420) Python warns about invalid escape sequences in the CBMC Makefile generation helpers. Use raw regex strings and escape the Windows path example so the parsed AST stays unchanged while removing the warnings. Signed-off-by: Old-Ding Co-authored-by: Old-Ding --- FreeRTOS/Test/CBMC/proofs/make_common_makefile.py | 8 ++++---- FreeRTOS/Test/CBMC/proofs/make_proof_makefiles.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/FreeRTOS/Test/CBMC/proofs/make_common_makefile.py b/FreeRTOS/Test/CBMC/proofs/make_common_makefile.py index f390885377..8e23bcab7d 100755 --- a/FreeRTOS/Test/CBMC/proofs/make_common_makefile.py +++ b/FreeRTOS/Test/CBMC/proofs/make_common_makefile.py @@ -30,7 +30,7 @@ import os import argparse def cleanup_whitespace(string): - return re.sub('\s+', ' ', string.strip()) + return re.sub(r'\s+', ' ', string.strip()) ################################################################ # Operating system specific values @@ -83,9 +83,9 @@ def patch_compile_output(opsys, line, key, value): if key in ["COMPILE_ONLY", "COMPILE_LINK"] and value is not None: if value[-1] == '/Fo': - return re.sub('/Fo\s+', '/Fo', line) + return re.sub(r'/Fo\s+', '/Fo', line) if value[-1] == '/Fe': - return re.sub('/Fe\s+', '/Fe', line) + return re.sub(r'/Fe\s+', '/Fe', line) return line ################################################################ @@ -181,7 +181,7 @@ def write_makefile(opsys, template, defines, makefile): with open(template) as _template: for line in _template: line = patch_path_separator(opsys, line) - keys = re.findall('@(\w+)@', line) + keys = re.findall(r'@(\w+)@', line) values = [find_definition(key, defines) for key in keys] for key, value in zip(keys, values): if value is not None: diff --git a/FreeRTOS/Test/CBMC/proofs/make_proof_makefiles.py b/FreeRTOS/Test/CBMC/proofs/make_proof_makefiles.py index 749852b196..2d1289d9b2 100755 --- a/FreeRTOS/Test/CBMC/proofs/make_proof_makefiles.py +++ b/FreeRTOS/Test/CBMC/proofs/make_proof_makefiles.py @@ -121,7 +121,7 @@ def prolog(): On Windows -> - H_INC = /Imy\cool\directory + H_INC = /Imy\\cool\\directory H_DEF = /DHALF=/2 When invoked, this script walks the directory tree looking for files