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
4545 # Initialize global dicts and regular expression
4646 disasm_cache = dict()
4747 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.*:")
5050 cache_size = 64*1024
5151
5252 glb_source_file_name = None
tools/perf/scripts/python/compaction-times.py+1−1
@@ -260,7 +260,7 @@ def pr_help(): · 259 unmodified lines
260260
261261 comm_re = None
262262 pid_re = None
263−pid_regex = "^(\d*)-(\d*)$|^(\d*)$"
263+pid_regex = r"^(\d*)-(\d*)$|^(\d*)$"
264264
265265 opt_proc = popt.DISP_DFL
266266 opt_disp = topt.DISP_ALL
tools/perf/scripts/python/exported-sql-viewer.py+2−2
@@ -677,8 +677,8 @@ class CallGraphModelBase(TreeModel): · 676 unmodified lines
677677 # sqlite supports GLOB (text only) which uses * and ? and is case sensitive
678678 if not self.glb.dbref.is_sqlite3:
679679 # Escape % and _
680− s = value.replace("%", "\%")
681− s = s.replace("_", "\_")
680+ s = value.replace("%", "\\%")
681+ s = s.replace("_", "\\_")
682682 # Translate * and ? into SQL LIKE pattern characters % and _
683683 trans = string.maketrans("*?", "%_")
684684 match = " LIKE '" + str(s).translate(trans) + "'"