Skip to content

Fix Python 3.12 regex SyntaxWarning in slugify whitespace collapsing - #1

Merged
markjm merged 1 commit into
masterfrom
copilot/featureapply-pr-41
Sep 16, 2026
Merged

markjm merged 1 commit into
masterfrom
copilot/featureapply-pr-41

Conversation

Copilot AI commented Sep 16, 2026

Copy link
Copy Markdown

This change ports upstream mozilla/unicode-slugify PR mozilla#41 into this fork to resolve a Python 3.12 SyntaxWarning triggered by the slug normalization regex. The warning came from a non-raw pattern string containing \s.

  • Root cause

    • The whitespace-collapse regex in slugify() used a normal string literal, so \s was parsed as an invalid escape sequence in Python 3.12 warning mode.
  • Change applied

    • Updated the regex pattern to a raw string in slugify/__init__.py:
      • from '[%s\s]+'
      • to r'[%s\s]+'
    • Behavior is preserved; only string-literal parsing semantics are corrected.
  • Patch excerpt

    # before
    new = re.sub('[%s\s]+' % space_replacement, space_replacement, new)
    
    # after
    new = re.sub(r'[%s\s]+' % space_replacement, space_replacement, new)

Co-authored-by: markjm <16494982+markjm@users.noreply.github.com>
@markjm

markjm commented Sep 16, 2026

Copy link
Copy Markdown
Owner

thanks bot

@markjm
markjm merged commit 9151a4f into master Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants