Skip to content

fix: replace invalid escape sequences in astparser.py#86

Open
Bindkushal wants to merge 1 commit intosugarlabs:masterfrom
Bindkushal:fix/invalid-escape-sequences-astparser
Open

fix: replace invalid escape sequences in astparser.py#86
Bindkushal wants to merge 1 commit intosugarlabs:masterfrom
Bindkushal:fix/invalid-escape-sequences-astparser

Conversation

@Bindkushal
Copy link

Fixes SyntaxWarning on Python 3.12+ where '.' in regular string
literals is treated as invalid escape sequence.

Changed '.' to '\.' in FLOAT_REGEXP_STR and RANGE_REGEXP.

@quozl
Copy link

quozl commented Mar 12, 2026

Is this related to the recent issues? Can you please review #83 too? Thanks.

@Bindkushal
Copy link
Author

@quozl Yes, this addresses the same issue as #83. , I will test #83 and submit the Revieve there

@Bindkushal
Copy link
Author

Bindkushal commented Mar 13, 2026

@quozl I reviewed #83 and the update #85 carefully. While the raw string approach is valid, it also modifies AST handling and introduces an unreachable elif isinstance(node, ast.Constant) check on line 496 — the first ast.Constant branch already handles all cases.

elif isinstance(node, ast.Constant):
return node.value

elif isinstance(node, ast.Constant) and isinstance(node.value, str):
return node.value

original cantorl flow was fine, in his updated #85 . The second elif can never be reached — it checks ast.Constant again but the first one already catches all ast.Constant nodes. Dead code. That's a bug he introduced.

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.

2 participants