Skip to content

fix: resolve Python 3.13 re.sub PatternError in bridge.py#383

Open
yoshida-m-3 wants to merge 1 commit intoasheshgoplani:mainfrom
yoshida-m-3:fix/python313-re-escape-in-bridge
Open

fix: resolve Python 3.13 re.sub PatternError in bridge.py#383
yoshida-m-3 wants to merge 1 commit intoasheshgoplani:mainfrom
yoshida-m-3:fix/python313-re-escape-in-bridge

Conversation

@yoshida-m-3
Copy link

Summary

  • Fix re.PatternError: bad escape \u at position 2 when running the conductor bridge with Python 3.13+
  • Change raw string r"\1\u2022 " to regular string "\\1\u2022 " in _markdown_to_slack() replacement pattern

Problem

Python 3.13 promoted the DeprecationWarning for invalid escape sequences in re.sub() replacement strings to a hard re.PatternError. The raw string r"\1\u2022 " contains \u which is not a valid regex escape, causing the bridge to crash on every message:

re.PatternError: bad escape \u at position 2

This prevents the Slack bridge from sending any responses back to the channel.

Fix

Replace the raw string with a regular string so that:

  • \\1 is interpreted as the regex backreference \1
  • \u2022 is interpreted as the Unicode bullet character by Python

Test plan

  • Verified on Python 3.13.12 — bridge processes messages and sends responses to Slack without errors
  • The replacement still produces the correct bullet character () in Slack output

Python 3.13 raises `re.PatternError: bad escape \u` when using
`r"\1\u2022 "` as a replacement string in `re.sub()`. In Python 3.12
and earlier this was silently accepted, but 3.13 promoted the
DeprecationWarning to a hard error.

Change the raw string `r"\1\u2022 "` to a regular string `"\\1\u2022 "`
so that `\1` is a proper backreference and `\u2022` (bullet character)
is interpreted as a Unicode literal by Python, not by the regex engine.
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.

1 participant