Support both Python 2 and Python 3 in Core.py. This should have no functional change.
Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all
Unified · Split
| @@ -31,10 +31,8 @@ def flag_str(event_name, field_name, value): · 30 unmodified lines | ||
| 31 | 31 | string = "" |
| 32 | 32 | |
| 33 | 33 | if flag_fields[event_name][field_name]: |
| 34 | − print_delim = 0 | |
| 35 | − keys = flag_fields[event_name][field_name]['values'].keys() | |
| 36 | − keys.sort() | |
| 37 | − for idx in keys: | |
| 34 | + print_delim = 0 | |
| 35 | + for idx in sorted(flag_fields[event_name][field_name]['values']): | |
| 38 | 36 | if not value and not idx: |
| 39 | 37 | string += flag_fields[event_name][field_name]['values'][idx] |
| 40 | 38 | break |
| @@ -51,14 +49,12 @@ def symbol_str(event_name, field_name, value): · 10 unmodified lines | ||
| 51 | 49 | string = "" |
| 52 | 50 | |
| 53 | 51 | if symbolic_fields[event_name][field_name]: |
| 54 | − keys = symbolic_fields[event_name][field_name]['values'].keys() | |
| 55 | − keys.sort() | |
| 56 | − for idx in keys: | |
| 52 | + for idx in sorted(symbolic_fields[event_name][field_name]['values']): | |
| 57 | 53 | if not value and not idx: |
| 58 | − string = symbolic_fields[event_name][field_name]['values'][idx] | |
| 54 | + string = symbolic_fields[event_name][field_name]['values'][idx] | |
| 59 | 55 | break |
| 60 | − if (value == idx): | |
| 61 | − string = symbolic_fields[event_name][field_name]['values'][idx] | |
| 56 | + if (value == idx): | |
| 57 | + string = symbolic_fields[event_name][field_name]['values'][idx] | |
| 62 | 58 | break |
| 63 | 59 | |
| 64 | 60 | return string |
| @@ -74,19 +70,17 @@ def trace_flag_str(value): · 9 unmodified lines | ||
| 74 | 70 | string = "" |
| 75 | 71 | print_delim = 0 |
| 76 | 72 | |
| 77 | − keys = trace_flags.keys() | |
| 78 | − | |
| 79 | − for idx in keys: | |
| 80 | − if not value and not idx: | |
| 81 | − string += "NONE" | |
| 82 | − break | |
| 83 | − | |
| 84 | − if idx and (value & idx) == idx: | |
| 85 | − if print_delim: | |
| 86 | − string += " | "; | |
| 87 | − string += trace_flags[idx] | |
| 88 | − print_delim = 1 | |
| 89 | − value &= ~idx | |
| 73 | + for idx in trace_flags: | |
| 74 | + if not value and not idx: | |
| 75 | + string += "NONE" | |
| 76 | + break | |
| 77 | + | |
| 78 | + if idx and (value & idx) == idx: | |
| 79 | + if print_delim: | |
| 80 | + string += " | "; | |
| 81 | + string += trace_flags[idx] | |
| 82 | + print_delim = 1 | |
| 83 | + value &= ~idx | |
| 90 | 84 | |
| 91 | 85 | return string |
| 92 | 86 | |