Fix invalid \\] escape sequence in conversation.py regex#27
Open
tundakk wants to merge 1 commit intotechartdev:mainfrom
Open
Fix invalid \\] escape sequence in conversation.py regex#27tundakk wants to merge 1 commit intotechartdev:mainfrom
tundakk wants to merge 1 commit intotechartdev:mainfrom
Conversation
…thon 3.12+ raises SyntaxWarning (3.14 SyntaxError) on the regex literal at conversation.py:316; the pattern was two adjacent string literals where the second was non-raw and contained \]. Consolidating into a single raw string preserves regex semantics. Co-Authored-By: Claude <noreply@anthropic.com>
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
The regex literal at
custom_components/openclaw/conversation.py:316is parsed by Python as two adjacent string literals rather than one. The second of those literals is non-raw and contains\], which Python 3.12+ flags asSyntaxWarning: invalid escape sequence '\]'and which Python 3.14 promotes toSyntaxError.The compiled regex character class is identical (
["'»)\]]); only the Python source representation changes. The redundant inner""was a no-op concatenation seam, not a deliberate character.Verification
python -W error::SyntaxWarning -c "import py_compile; py_compile.compile('conversation.py', doraise=True)"— passes after the fix, fails before.Are you sure?,Are you sure? ",Are you sure? »,Are you sure?)and rejectsStatement.(verified locally).Test plan
SyntaxWarningon import ofconversation.py._is_likely_question_followupfollow-up detection.