data, web: use raw strings for regex patterns

\d and \w in non-raw strings are invalid escape sequences that
generate SyntaxWarning in Python 3.12+ and will become SyntaxError in
a future version. Use rb'...' / r'...' to silence the warning and
future-proof the patterns.

Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
This commit is contained in:
Thomas Perrot 2026-05-05 17:37:56 +02:00 committed by Théo Lebrun
parent a54519731f
commit 4a0c0797d1
2 changed files with 3 additions and 3 deletions

View file

@ -25,8 +25,8 @@ import os
import os.path import os.path
import errno import errno
deflist_regex = re.compile(b'(\d*)(\w)(\d*)(\w),?') deflist_regex = re.compile(rb'(\d*)(\w)(\d*)(\w),?')
deflist_macro_regex = re.compile('\dM\d+(\w)') deflist_macro_regex = re.compile(r'\dM\d+(\w)')
################################################################################## ##################################################################################

View file

@ -560,7 +560,7 @@ def generate_source(q: Query, project: str, version: str, path: str) -> str:
html_code_block = format_code(fname, code) html_code_block = format_code(fname, code)
# Replace line numbers by links to the corresponding line in the current file # Replace line numbers by links to the corresponding line in the current file
html_code_block = sub('href="#codeline-(\d+)', 'name="L\\1" id="L\\1" href="#L\\1', html_code_block) html_code_block = sub(r'href="#codeline-(\d+)', 'name="L\\1" id="L\\1" href="#L\\1', html_code_block)
for f in filters: for f in filters:
html_code_block = f.untransform_formatted_code(filter_ctx, html_code_block) html_code_block = f.untransform_formatted_code(filter_ctx, html_code_block)