ucalls: fix map behaviour on python3
authorRafael Fonseca <rdossant@redhat.com>
Mon, 13 Feb 2017 14:46:54 +0000 (15:46 +0100)
committerRafael Fonseca <rdossant@redhat.com>
Mon, 13 Feb 2017 14:49:13 +0000 (15:49 +0100)
On python3 map returns a generator instead of a list. This fixes the
following error:

Traceback (most recent call last):
  File "./ucalls", line 280, in <module>
    data = get_data()   # [(function, (num calls, latency in ns))]
  File "./ucalls", line 255, in get_data
    data.extend(syscalls)
AttributeError: 'map' object has no attribute 'extend'

tools/ucalls.py

index ed476cd..83727b3 100755 (executable)
@@ -236,12 +236,12 @@ if args.syscalls:
 def get_data():
     # Will be empty when no language was specified for tracing
     if args.latency:
-        data = map(lambda (k, v): (k.clazz + "." + k.method,
+        data = list(map(lambda (k, v): (k.clazz + "." + k.method,
                                    (v.num_calls, v.total_ns)),
-                   bpf["times"].items())
+                   bpf["times"].items()))
     else:
-        data = map(lambda (k, v): (k.clazz + "." + k.method, (v.value, 0)),
-                   bpf["counts"].items())
+        data = list(map(lambda (k, v): (k.clazz + "." + k.method, (v.value, 0)),
+                   bpf["counts"].items()))
 
     if args.syscalls:
         if args.latency: