-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Are there any related issues?
Not that I could find.
Description of the Issue
When I run t graph, the following warning is printed before the graph (the graph is fine though!):
SyntaxWarning: invalid escape sequence '\d'
m = re.match("x ([\d]{4}-[\d]{2}-[\d]{2}).*", line)I am using Python 3.12.6.
Additional Information
It is noted in the Python 3 documentation for re that:
any invalid escape sequences in Python’s usage of the backslash in string literals now generate a SyntaxWarning and in the future this will become a SyntaxError. This behaviour will happen even if it is a valid escape sequence for a regular expression.
and the solution is to prefix the pattern string with an 'r':
The solution is to use Python’s raw string notation for regular expression patterns; backslashes are not handled in any special way in a string literal prefixed with 'r'.
I'm not sure when the warning was added, but prefixing regex pattern strings with 'r' goes at least as far back as Python 2.6, so there shouldn't be any compatibility issues if you add it.
Edit: One more note from the Python docs, this warning is planned to become an error at some point in the future:
Also, please note that any invalid escape sequences in Python’s usage of the backslash in string literals now generate a SyntaxWarning and in the future this will become a SyntaxError.