The script allows the user to enter patterns to find symbols. The pattern matching characters are converted for use in SQL. For PostgreSQL the conversion involves using the Python maketrans() method which is slightly different in Python 3 compared with Python 2. Fix to work in Python 3.
Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all
Unified · Split
| @@ -680,7 +680,10 @@ class CallGraphModelBase(TreeModel): · 679 unmodified lines | |||
| 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 | if sys.version_info[0] == 3: |
| 684 | trans = str.maketrans("*?", "%_") | ||
| 685 | else: | ||
| 686 | trans = string.maketrans("*?", "%_") | ||
| 684 | match = " LIKE '" + str(s).translate(trans) + "'" | 687 | match = " LIKE '" + str(s).translate(trans) + "'" |
| 685 | else: | 688 | else: |
| 686 | match = " GLOB '" + str(value) + "'" | 689 | match = " GLOB '" + str(value) + "'" |