summaryrefslogtreecommitdiffstats
path: root/bsp/meta-freescale/recipes-graphics/imx-gpu-apitrace/imx-gpu-apitrace/0003-scripts-Tie-Python-2-3-conversion-loose-ends.patch
blob: e30273d530b343e6081af89d107eae022307f925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
From 8ba82a1ef77e60bd614cca1e583e1a0c25b4f281 Mon Sep 17 00:00:00 2001
From: Jose Fonseca <jfonseca@vmware.com>
Date: Sun, 28 Apr 2019 14:14:44 +0100
Subject: [PATCH 3/4] scripts: Tie Python 2 -> 3 conversion loose ends.

Upstream-Status: Backport [https://github.com/apitrace/apitrace/commit/247e1fa87f4e87b8914662e44a8ecef4d444cc90]

(cherry picked from commit 247e1fa87f4e87b8914662e44a8ecef4d444cc90)
Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
---
 retrace/glstate_params.py    |  2 +-
 scripts/convert.py           |  2 +-
 scripts/highlight.py         |  3 ++-
 scripts/jsondiff.py          |  2 +-
 scripts/jsonextractimages.py |  2 +-
 scripts/leaks.py             |  4 ++--
 scripts/profileshader.py     |  2 +-
 scripts/retracediff.py       |  2 +-
 scripts/snapdiff.py          |  2 +-
 scripts/tracecheck.py        |  2 +-
 scripts/tracediff.py         | 10 +++++-----
 scripts/unpickle.py          | 19 ++++++++++---------
 12 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/retrace/glstate_params.py b/retrace/glstate_params.py
index bc90f66b..55f2dbc9 100755
--- a/retrace/glstate_params.py
+++ b/retrace/glstate_params.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 ##########################################################################
 #
 # Copyright 2011 Jose Fonseca
diff --git a/scripts/convert.py b/scripts/convert.py
index 83df70ce..1f285a8c 100755
--- a/scripts/convert.py
+++ b/scripts/convert.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 ##########################################################################
 #
 # Copyright 2012 VMware Inc.
diff --git a/scripts/highlight.py b/scripts/highlight.py
index ed3b54d4..e494abf4 100644
--- a/scripts/highlight.py
+++ b/scripts/highlight.py
@@ -221,7 +221,8 @@ def LessHighlighter():
         try:
             less = subprocess.Popen(
                 args = ['less', '-FRXn'],
-                stdin = subprocess.PIPE
+                stdin = subprocess.PIPE,
+                universal_newlines = True
             )
         except OSError:
             return ColorHighlighter()
diff --git a/scripts/jsondiff.py b/scripts/jsondiff.py
index 25c4840e..d7a18e21 100755
--- a/scripts/jsondiff.py
+++ b/scripts/jsondiff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 ##########################################################################
 #
 # Copyright 2015 VMware, Inc.
diff --git a/scripts/jsonextractimages.py b/scripts/jsonextractimages.py
index 917ee7e4..785e32db 100755
--- a/scripts/jsonextractimages.py
+++ b/scripts/jsonextractimages.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 ##########################################################################
 #
 # Copyright 2012 Jose Fonseca
diff --git a/scripts/leaks.py b/scripts/leaks.py
index 325af1e2..706e60a9 100755
--- a/scripts/leaks.py
+++ b/scripts/leaks.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 ##########################################################################
 #
 # Copyright 2014-2016 VMware, Inc.
@@ -39,7 +39,7 @@ class LeakDetector(unpickle.Unpickler):
     def __init__(self, apitrace, trace):
 
         cmd = [apitrace, 'pickle', '--symbolic', trace]
-        p = subprocess.Popen(args = cmd, stdout = subprocess.PIPE)
+        p = subprocess.Popen(args = cmd, stdout=subprocess.PIPE)
 
         unpickle.Unpickler.__init__(self, p.stdout)
 
diff --git a/scripts/profileshader.py b/scripts/profileshader.py
index 5c2a58fb..c6c1c935 100755
--- a/scripts/profileshader.py
+++ b/scripts/profileshader.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 ##########################################################################
 #
 # Copyright 2012-2013 VMware, Inc.
diff --git a/scripts/retracediff.py b/scripts/retracediff.py
index 8105f536..967f3a93 100755
--- a/scripts/retracediff.py
+++ b/scripts/retracediff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 ##########################################################################
 #
 # Copyright 2011 Jose Fonseca
diff --git a/scripts/snapdiff.py b/scripts/snapdiff.py
index b0d5f757..58fefe88 100755
--- a/scripts/snapdiff.py
+++ b/scripts/snapdiff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 ##########################################################################
 #
 # Copyright 2011 Jose Fonseca
diff --git a/scripts/tracecheck.py b/scripts/tracecheck.py
index 3a2ec452..38167e89 100755
--- a/scripts/tracecheck.py
+++ b/scripts/tracecheck.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 ##########################################################################
 #
 # Copyright 2011 VMware, Inc.
diff --git a/scripts/tracediff.py b/scripts/tracediff.py
index 0cd9c8c6..88e389a3 100755
--- a/scripts/tracediff.py
+++ b/scripts/tracediff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 ##########################################################################
 #
 # Copyright 2011 Jose Fonseca
@@ -173,7 +173,7 @@ class ExternalDiffer(Differ):
             try:
                 less = subprocess.Popen(
                     args = ['less', '-FRXn'],
-                    stdin = subprocess.PIPE
+                    stdin = subprocess.PIPE,
                 )
             except OSError:
                 pass
@@ -214,7 +214,7 @@ ignoredFunctionNames = set([
 
 
 class Blob:
-    '''Data-less proxy for bytearrays, to save memory.'''
+    '''Data-less proxy for bytes, to save memory.'''
 
     def __init__(self, size, hash):
         self.size = size
@@ -233,7 +233,7 @@ class Blob:
 class BlobReplacer(Rebuilder):
     '''Replace blobs with proxys.'''
 
-    def visitByteArray(self, obj):
+    def visitBytes(self, obj):
         return Blob(len(obj), hash(str(obj)))
 
     def visitCall(self, call):
@@ -287,7 +287,7 @@ class PythonDiffer(Differ):
                 '--calls=' + calls,
                 trace
             ],
-            stdout = subprocess.PIPE,
+            stdout=subprocess.PIPE,
         )
 
         parser = Loader(p.stdout)
diff --git a/scripts/unpickle.py b/scripts/unpickle.py
index 86891d29..822b8ea8 100755
--- a/scripts/unpickle.py
+++ b/scripts/unpickle.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 ##########################################################################
 #
 # Copyright 2012 Jose Fonseca
@@ -34,6 +34,7 @@ Run as:
 
 
 import itertools
+import operator
 import optparse
 import sys
 import time
@@ -55,7 +56,7 @@ CALL_FLAG_MARKER_PUSH       = (1 << 9)
 CALL_FLAG_MARKER_POP        = (1 << 10)
 
 
-class Pointer(long):
+class Pointer(int):
 
     def __str__(self):
         if self == 0:
@@ -79,7 +80,7 @@ class Visitor:
         self.dispatch[tuple] = self.visitTuple
         self.dispatch[list] = self.visitList
         self.dispatch[dict] = self.visitDict
-        self.dispatch[bytearray] = self.visitByteArray
+        self.dispatch[bytes] = self.visitBytes
         self.dispatch[Pointer] = self.visitPointer
 
     def visit(self, obj):
@@ -119,7 +120,7 @@ class Visitor:
     def visitDict(self, obj):
         return self.visitIterable(obj)
 
-    def visitByteArray(self, obj):
+    def visitBytes(self, obj):
         raise NotImplementedError
 
     def visitPointer(self, obj):
@@ -153,7 +154,7 @@ class Dumper(Visitor):
     def visitDict(self, obj):
         return '{' + self.visitItems(iter(obj.items())) + '}'
 
-    def visitByteArray(self, obj):
+    def visitBytes(self, obj):
         return 'blob(%u)' % len(obj)
 
 
@@ -169,7 +170,7 @@ class Hasher(Visitor):
     def visitIterable(self, obj):
         return tuple(map(self.visit, obj))
 
-    def visitByteArray(self, obj):
+    def visitBytes(self, obj):
         return str(obj)
 
 
@@ -193,7 +194,7 @@ class Rebuilder(Visitor):
         else:
             return obj
 
-    def visitByteArray(self, obj):
+    def visitBytes(self, obj):
         return obj
 
 
@@ -269,7 +270,7 @@ class Counter(Unpickler):
         Unpickler.parse(self)
 
         functionFrequencies = list(self.functionFrequencies.items())
-        functionFrequencies.sort(lambda (name1, freq1), (name2, freq2): cmp(freq1, freq2))
+        functionFrequencies.sort(key=operator.itemgetter(1))
         for name, frequency in functionFrequencies:
             sys.stdout.write('%8u %s\n' % (frequency, name))
 
@@ -311,7 +312,7 @@ def main():
         msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
 
     startTime = time.time()
-    parser = Counter(sys.stdin, options.verbose)
+    parser = Counter(sys.stdin.buffer, options.verbose)
     parser.parse()
     stopTime = time.time()
     duration = stopTime - startTime
-- 
2.17.1