ply icon indicating copy to clipboard operation
ply copied to clipboard

Fix invalid escape sequence SyntaxWarning for '\#'

Open echoix opened this issue 1 year ago • 0 comments

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

echoix avatar Oct 06 '24 11:10 echoix