fix: resolve Python 3.13 re.sub PatternError in bridge.py#383
Open
yoshida-m-3 wants to merge 1 commit intoasheshgoplani:mainfrom
Open
fix: resolve Python 3.13 re.sub PatternError in bridge.py#383yoshida-m-3 wants to merge 1 commit intoasheshgoplani:mainfrom
yoshida-m-3 wants to merge 1 commit intoasheshgoplani:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
re.PatternError: bad escape \u at position 2when running the conductor bridge with Python 3.13+r"\1\u2022 "to regular string"\\1\u2022 "in_markdown_to_slack()replacement patternProblem
Python 3.13 promoted the
DeprecationWarningfor invalid escape sequences inre.sub()replacement strings to a hardre.PatternError. The raw stringr"\1\u2022 "contains\uwhich is not a valid regex escape, causing the bridge to crash on every message:This prevents the Slack bridge from sending any responses back to the channel.
Fix
Replace the raw string with a regular string so that:
\\1is interpreted as the regex backreference\1\u2022is interpreted as the Unicode bullet character•by PythonTest plan
•) in Slack output