Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf scripts python: Add Python 3 support to Util.py

Support both Python 2 and Python 3 in Util.py. The dict class no longer
has a ``has_key`` method and print is now a function rather than a
statement. This should have no functional change.

Signed-off-by: Jeremy Cline <jeremy@jcline.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Herton Krzesinski <herton@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/0100016341a730c6-8db8b9b1-da2d-4ee3-96bf-47e0ae9796bd-000000@email.amazonses.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jeremy Cline and committed by
Arnaldo Carvalho de Melo
c45b168e 2ab89262

+6 -5
+6 -5
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
··· 5 5 # This software may be distributed under the terms of the GNU General 6 6 # Public License ("GPL") version 2 as published by the Free Software 7 7 # Foundation. 8 + from __future__ import print_function 8 9 9 10 import errno, os 10 11 ··· 34 33 return str 35 34 36 35 def add_stats(dict, key, value): 37 - if not dict.has_key(key): 36 + if key not in dict: 38 37 dict[key] = (value, value, value, 1) 39 38 else: 40 39 min, max, avg, count = dict[key] ··· 73 72 except: 74 73 if not audit_package_warned: 75 74 audit_package_warned = True 76 - print "Install the audit-libs-python package to get syscall names.\n" \ 77 - "For example:\n # apt-get install python-audit (Ubuntu)" \ 78 - "\n # yum install audit-libs-python (Fedora)" \ 79 - "\n etc.\n" 75 + print("Install the audit-libs-python package to get syscall names.\n" 76 + "For example:\n # apt-get install python-audit (Ubuntu)" 77 + "\n # yum install audit-libs-python (Fedora)" 78 + "\n etc.\n") 80 79 81 80 def syscall_name(id): 82 81 try: