https://bugs.kde.org/show_bug.cgi?id=476708

            Bug ID: 476708
           Summary: valgrind-monitor.py regular expressions should use raw
                    strings
    Classification: Developer tools
           Product: valgrind
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: jsew...@acm.org
          Reporter: m...@klomp.org
  Target Milestone: ---

/usr/share/gdb/auto-load/valgrind-monitor-def.py:214: SyntaxWarning: invalid
escape sequence '\['
  if re.fullmatch("^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str):
Loaded /usr/share/gdb/auto-load/valgrind-monitor.py

According to
https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes

A backslash-character pair that is not a valid escape sequence now generates a
SyntaxWarning, instead of DeprecationWarning. For example,
re.compile("\d+\.\d+") now emits a SyntaxWarning ("\d" is an invalid escape
sequence, use raw strings for regular expression: re.compile(r"\d+\.\d+")). In
a future Python version, SyntaxError will eventually be raised, instead of
SyntaxWarning. (Contributed by Victor Stinner in gh-98401.)

Using a raw string does indeed get rid of the SyntaxWarning:

if re.fullmatch(r"^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str):

Probably all regexps should use raw strings if they contain escape sequences.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to