History

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.

Benjamin Gray committed 3 years ago

Commit 280b4e41 parent acbf6de4 files · +6 −6Browse files

Showing the changes to tools/perf/scripts/python (3 of 4 files). Show all

Unified · Split

3 files
  1. tools/perf/scripts/python/arm-cs-trace-disasm.py +2 −2
  2. tools/perf/scripts/python/compaction-times.py +1 −1
  3. tools/perf/scripts/python/exported-sql-viewer.py +2 −2
tools/perf/scripts/python/arm-cs-trace-disasm.py+2−2
@@ -45,8 +45,8 @@ parser = OptionParser(option_list=option_list) · 44 unmodified lines
45# Initialize global dicts and regular expression45# Initialize global dicts and regular expression
46disasm_cache = dict()46disasm_cache = dict()
47cpu_data = dict()47cpu_data = dict()
48disasm_re = re.compile("^\s*([0-9a-fA-F]+):")48disasm_re = re.compile(r"^\s*([0-9a-fA-F]+):")
49disasm_func_re = re.compile("^\s*([0-9a-fA-F]+)\s.*:")49disasm_func_re = re.compile(r"^\s*([0-9a-fA-F]+)\s.*:")
50cache_size = 64*102450cache_size = 64*1024
51 51
52glb_source_file_name = None52glb_source_file_name = None
tools/perf/scripts/python/compaction-times.py+1−1
@@ -260,7 +260,7 @@ def pr_help(): · 259 unmodified lines
260 260
261comm_re = None261comm_re = None
262pid_re = None262pid_re = None
263pid_regex = "^(\d*)-(\d*)$|^(\d*)$"263pid_regex = r"^(\d*)-(\d*)$|^(\d*)$"
264 264
265opt_proc = popt.DISP_DFL265opt_proc = popt.DISP_DFL
266opt_disp = topt.DISP_ALL266opt_disp = topt.DISP_ALL
tools/perf/scripts/python/exported-sql-viewer.py+2−2
@@ -677,8 +677,8 @@ class CallGraphModelBase(TreeModel): · 676 unmodified lines
677 # sqlite supports GLOB (text only) which uses * and ? and is case sensitive677 # sqlite supports GLOB (text only) which uses * and ? and is case sensitive
678 if not self.glb.dbref.is_sqlite3:678 if not self.glb.dbref.is_sqlite3:
679 # Escape % and _679 # Escape % and _
680 s = value.replace("%", "\%")680 s = value.replace("%", "\\%")
681 s = s.replace("_", "\_")681 s = s.replace("_", "\\_")
682 # Translate * and ? into SQL LIKE pattern characters % and _682 # Translate * and ? into SQL LIKE pattern characters % and _
683 trans = string.maketrans("*?", "%_")683 trans = string.maketrans("*?", "%_")
684 match = " LIKE '" + str(s).translate(trans) + "'"684 match = " LIKE '" + str(s).translate(trans) + "'"