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/exported-sql-viewer.py (1 of 4 files). Show all

Unified · Split

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) + "'"