Skip to content
This repository was archived by the owner on Dec 21, 2025. It is now read-only.

Fix invalid escape sequence SyntaxWarning for '\#' - #307

Open
echoix wants to merge 1 commit into
dabeaz:masterfrom
echoix:invalid-escape-sequence
Open

Fix invalid escape sequence SyntaxWarning for '\#'#307
echoix wants to merge 1 commit into
dabeaz:masterfrom
echoix:invalid-escape-sequence

Conversation

@echoix

@echoix echoix commented Oct 6, 2024

Copy link
Copy Markdown

In the test file testlex.py, at line 193, on newer Python versions (3.12+), a SyntaxWarning is emitted when an invalid escape sequence is encountered, just like this:

ply/tests/testlex.py:193: SyntaxWarning: invalid escape sequence '\#'
  "ERROR: Make sure '#' in rule 't_POUND' is escaped with '\#'")

This PR changes the line to use a raw string for this. Raw strings were supported even in Python 2.7, so there is no problem here. See https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant