Skip to content

Commit

Permalink
Python 3.12 introduces a new warning for invalid escape sequences for…
Browse files Browse the repository at this point in the history
… some regex strings. (#586)

Update string literal notation for regex.
  • Loading branch information
jmartin-tech authored Apr 8, 2024
1 parent bbfb3fe commit eb82b47
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions garak/resources/autodan/genetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb82b47

Please sign in to comment.