Closed
Description
Python 3.12 improves handling of incorrect escape sequences, see https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
This is a typical scenario in regular expressions. With Python 3.12, there are currently 5 places that use invalid escape sequences:
-
examples/tracing/task_switch.py:9: SyntaxWarning: invalid escape sequence '\.' b.attach_kprobe(event_re="^finish_task_switch$|^finish_task_switch\.isra\.\d$",
-
src/python/bcc/__init__.py:758: SyntaxWarning: invalid escape sequence '\.' elif re.match(b'^.*\.cold(\.\d+)?$', fn):
-
tests/python/test_tools_smoke.py:67: SyntaxWarning: invalid escape sequence '\s' reg = re.compile("^%s\s" % mod)
-
tests/python/test_trace2.py:34: SyntaxWarning: invalid escape sequence '\.' b.attach_kprobe(event_re=b"^finish_task_switch$|^finish_task_switch\.isra\.\d$",
-
tools/exitsnoop.py:207: SyntaxWarning: invalid escape sequence '\.' if re.match('^3\.10\..*el7.*$', platform.release()): # Centos/Red Hat
In all places I think it will be enough to use Python raw strings, r'...'
.
Here is the command I used to look up all of them:
for f in $(git ls-files | grep -E '\.py$'); do python3 -m py_compile $f; done
Metadata
Metadata
Assignees
Labels
No labels