From 4a0c0797d101b35de4a4db1161e0fbda93db4e8b Mon Sep 17 00:00:00 2001 From: Thomas Perrot Date: Tue, 5 May 2026 17:37:56 +0200 Subject: [PATCH] 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 --- elixir/data.py | 4 ++-- elixir/web.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elixir/data.py b/elixir/data.py index b952943..86d1d23 100755 --- a/elixir/data.py +++ b/elixir/data.py @@ -25,8 +25,8 @@ import os import os.path import errno -deflist_regex = re.compile(b'(\d*)(\w)(\d*)(\w),?') -deflist_macro_regex = re.compile('\dM\d+(\w)') +deflist_regex = re.compile(rb'(\d*)(\w)(\d*)(\w),?') +deflist_macro_regex = re.compile(r'\dM\d+(\w)') ################################################################################## diff --git a/elixir/web.py b/elixir/web.py index 324a788..1e0588d 100755 --- a/elixir/web.py +++ b/elixir/web.py @@ -560,7 +560,7 @@ def generate_source(q: Query, project: str, version: str, path: str) -> str: html_code_block = format_code(fname, code) # 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: html_code_block = f.untransform_formatted_code(filter_ctx, html_code_block)