Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Address python 3.6 DeprecationWarning for string scapes

Python 3.6 introduced a DeprecationWarning for invalid escape sequences.
This is upgraded to a SyntaxWarning in Python 3.12, and will eventually
be a syntax error.

Fix these now to get ahead of it before it's an error.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mykola Lysenko <mykolal@fb.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Todd E Brandt <todd.e.brandt@linux.intel.com>
Cc: Tom Rix <trix@redhat.com>
Cc: linux-doc@vger.kernel.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: llvm@lists.linux.dev
Link: https://lore.kernel.org/r/20230912060801.95533-6-bgray@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Benjamin Gray and committed by
Arnaldo Carvalho de Melo
280b4e4a acbf6de6

+6 -6
+1 -1
tools/perf/pmu-events/jevents.py
··· 83 83 """Return the length of s a C string 84 84 85 85 This doesn't handle all escape characters properly. It first assumes 86 - all \ are for escaping, it then adjusts as it will have over counted 86 + all \\ are for escaping, it then adjusts as it will have over counted 87 87 \\. The code uses \000 rather than \0 as a terminator as an adjacent 88 88 number would be folded into a string of \0 (ie. "\0" + "5" doesn't 89 89 equal a terminator followed by the number 5 but the escape of
+2 -2
tools/perf/scripts/python/arm-cs-trace-disasm.py
··· 45 45 # Initialize global dicts and regular expression 46 46 disasm_cache = dict() 47 47 cpu_data = dict() 48 - disasm_re = re.compile("^\s*([0-9a-fA-F]+):") 49 - disasm_func_re = re.compile("^\s*([0-9a-fA-F]+)\s.*:") 48 + disasm_re = re.compile(r"^\s*([0-9a-fA-F]+):") 49 + disasm_func_re = re.compile(r"^\s*([0-9a-fA-F]+)\s.*:") 50 50 cache_size = 64*1024 51 51 52 52 glb_source_file_name = None
+1 -1
tools/perf/scripts/python/compaction-times.py
··· 260 260 261 261 comm_re = None 262 262 pid_re = None 263 - pid_regex = "^(\d*)-(\d*)$|^(\d*)$" 263 + pid_regex = r"^(\d*)-(\d*)$|^(\d*)$" 264 264 265 265 opt_proc = popt.DISP_DFL 266 266 opt_disp = topt.DISP_ALL
+2 -2
tools/perf/scripts/python/exported-sql-viewer.py
··· 677 677 # sqlite supports GLOB (text only) which uses * and ? and is case sensitive 678 678 if not self.glb.dbref.is_sqlite3: 679 679 # Escape % and _ 680 - s = value.replace("%", "\%") 681 - s = s.replace("_", "\_") 680 + s = value.replace("%", "\\%") 681 + s = s.replace("_", "\\_") 682 682 # Translate * and ? into SQL LIKE pattern characters % and _ 683 683 trans = string.maketrans("*?", "%_") 684 684 match = " LIKE '" + str(s).translate(trans) + "'"