From eb82b472dbe378e18a64557cd855e90200a54ef8 Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Mon, 8 Apr 2024 10:02:45 -0500 Subject: [PATCH] Python 3.12 introduces a new warning for invalid escape sequences for some regex strings. (#586) Update string literal notation for regex. --- garak/resources/autodan/genetic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/garak/resources/autodan/genetic.py b/garak/resources/autodan/genetic.py index 5ba4395e0..f45d52a65 100644 --- a/garak/resources/autodan/genetic.py +++ b/garak/resources/autodan/genetic.py @@ -223,8 +223,8 @@ def crossover(str1: str, str2: str, num_points: int) -> Tuple[str, str]: Returns: Tuple of strings after `num_points` crossovers. """ - sentences1 = [s for s in re.split("(?<=[.!?])\s+", str1) if s] - sentences2 = [s for s in re.split("(?<=[.!?])\s+", str2) if s] + sentences1 = [s for s in re.split(r"(?<=[.!?])\s+", str1) if s] + sentences2 = [s for s in re.split(r"(?<=[.!?])\s+", str2) if s] max_swaps = min(len(sentences1), len(sentences2)) - 1 # Catch rare case where max_swaps is negative