]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
valgrind-monitor.py regular expressions should use raw strings
authorMark Wielaard <mark@klomp.org>
Fri, 17 Nov 2023 12:31:52 +0000 (13:31 +0100)
committerMark Wielaard <mark@klomp.org>
Fri, 17 Nov 2023 12:36:46 +0000 (13:36 +0100)
With python 3.12 gdb will produce the following SyntaxWarning when
loading valgrind-monitor-def.py:

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

In a future python version this will become an SyntaxError.

Use a raw strings for the regular expression.

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

NEWS
coregrind/m_gdbserver/valgrind-monitor-def.py

diff --git a/NEWS b/NEWS
index 98c2ecf1370d8ab02cd26720fb9b26ab37c4ac5f..93ab2f08ba29f746e53163af3ffbad3193adcf48 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 476320  Build failure with GCC
 476535  Difference in allocation size for massif/tests/overloaded-new between
         clang++/libc++ and g++/libstdc++
+476708  valgrind-monitor.py regular expressions should use raw strings
 476780  Extend strlcat and strlcpy wrappers to GNU libc
 476787  Build of Valgrind 3.21.0 fails when SOLARIS_PT_SUNDWTRACE_THRP is
         defined
index b4e7b992dc984d74d0bf5cb8222a53e0cd6dccd4..d74b1590cc125852b07e26ebcfbb2bcd5b014815 100644 (file)
@@ -211,7 +211,7 @@ class Valgrind_ADDR_LEN_opt(Valgrind_Command):
 For compatibility reason with the Valgrind gdbserver monitor command,
 we detect and accept usages such as 0x1234ABCD[10]."""
     def invoke(self, arg_str : str, from_tty : bool) -> None:
-        if re.fullmatch("^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str):
+        if re.fullmatch(r"^0x[0123456789ABCDEFabcdef]+\[[^\[\]]+\]$", arg_str):
             arg_str = arg_str.replace("[", " ")
             arg_str = arg_str.replace("]", " ")
         eval_execute_2(self, arg_str,