Conversation
….12+) Several detection patterns in tokens.py are plain (non-raw) strings that contain sequences such as \=, \<, \>, \W and \s. On Python 3.12+ these emit SyntaxWarning: invalid escape sequence and are scheduled to become a SyntaxError in a future release. Only the backslashes that form an invalid escape are doubled, which leaves every regex value (and therefore the matching behaviour) exactly the same while removing the warnings.
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.
What
Several detection patterns in
tokens.py(e.g.CLEAN_TOKEN_STEP1,GOOGLE_SECRET,TWILIO_AUTH) are plain non raw strings containing sequences like\=,\<,\>,\Wand\s.Why
On Python 3.12+ each of these emits
SyntaxWarning: invalid escape sequencewhen gitGraber is imported, and CPython has scheduled them to become aSyntaxErrorin a future release.Fix
Only the backslashes that form an invalid escape are doubled. Because an unrecognized escape currently passes the backslash through unchanged, doubling yields the exact same string value, so every compiled regex is byte for byte identical and detection behaviour is unchanged.
Validation: string-constant multiset identical before/after, and
python3 -W error::SyntaxWarning -m py_compile tokens.pyis clean.