summaryrefslogtreecommitdiff
path: root/build-python3-conversion.patch
blob: 4ac9ed626fda01178f5a3957d0043d2d2ac5f1ad (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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
Index: xen-4.13.0-testing/Config.mk
===================================================================
--- xen-4.13.0-testing.orig/Config.mk
+++ xen-4.13.0-testing/Config.mk
@@ -82,7 +82,7 @@ EXTRA_INCLUDES += $(EXTRA_PREFIX)/includ
 EXTRA_LIB += $(EXTRA_PREFIX)/lib
 endif
 
-PYTHON      ?= python
+PYTHON      ?= python3
 PYTHON_PREFIX_ARG ?= --prefix="$(prefix)"
 # The above requires that prefix contains *no spaces*. This variable is here
 # to permit the user to set PYTHON_PREFIX_ARG to '' to workaround this bug:
Index: xen-4.13.0-testing/tools/configure
===================================================================
--- xen-4.13.0-testing.orig/tools/configure
+++ xen-4.13.0-testing/tools/configure
@@ -6926,7 +6926,7 @@ then
 fi;;
 esac
 if test -z "$PYTHON"; then :
-  for ac_prog in python python3 python2
+  for ac_prog in python3 python python2
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -7065,15 +7065,15 @@ if test x"${PYTHONPATH}" = x"no"
 then
     as_fn_error $? "Unable to find $PYTHON, please install $PYTHON" "$LINENO" 5
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for python version >= 2.6 " >&5
-$as_echo_n "checking for python version >= 2.6 ... " >&6; }
-`$PYTHON -c 'import sys; sys.exit(eval("sys.version_info < (2, 6)"))'`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for python3 version >= 3.0 " >&5
+$as_echo_n "checking for python3 version >= 3.0 ... " >&6; }
+`$PYTHON -c 'import sys; sys.exit(eval("sys.version_info < (3, 0)"))'`
 if test "$?" != "0"
 then
     python_version=`$PYTHON -V 2>&1`
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-    as_fn_error $? "$python_version is too old, minimum required version is 2.6" "$LINENO" 5
+    as_fn_error $? "$python_version is too old, minimum required version is 3.0" "$LINENO" 5
 else
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
Index: xen-4.13.0-testing/tools/python/test.py
===================================================================
--- xen-4.13.0-testing.orig/tools/python/test.py
+++ xen-4.13.0-testing/tools/python/test.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python2.3
+#!/usr/bin/python3
 ##############################################################################
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
@@ -289,9 +289,9 @@ class ImmediateTestResult(unittest._Text
     def stopTest(self, test):
         self._testtimes[test] = time.time() - self._testtimes[test]
         if gc.garbage:
-            print "The following test left garbage:"
-            print test
-            print gc.garbage
+            print("The following test left garbage:")
+            print(test)
+            print(gc.garbage)
             # XXX Perhaps eat the garbage here, so that the garbage isn't
             #     printed for every subsequent test.
 
@@ -301,23 +301,23 @@ class ImmediateTestResult(unittest._Text
                              and
                              t not in self._threads)]
         if new_threads:
-            print "The following test left new threads behind:"
-            print test
-            print "New thread(s):", new_threads
+            print("The following test left new threads behind:")
+            print(test)
+            print("New thread(s):", new_threads)
 
     def print_times(self, stream, count=None):
-        results = self._testtimes.items()
+        results = list(self._testtimes.items())
         results.sort(lambda x, y: cmp(y[1], x[1]))
         if count:
             n = min(count, len(results))
             if n:
-                print >>stream, "Top %d longest tests:" % n
+                print("Top %d longest tests:" % n, file=stream)
         else:
             n = len(results)
         if not n:
             return
         for i in range(n):
-            print >>stream, "%6dms" % int(results[i][1] * 1000), results[i][0]
+            print("%6dms" % int(results[i][1] * 1000), results[i][0], file=stream)
 
     def _print_traceback(self, msg, err, test, errlist):
         if self.showAll or self.dots or self._progress:
@@ -369,7 +369,7 @@ class ImmediateTestResult(unittest._Text
         if self._progress:
             self.stream.write("\r")
         if self._debug:
-            raise err[0], err[1], err[2]
+            raise err[0](err[1]).with_traceback(err[2])
         self._print_traceback("Error in test %s" % test, err,
                               test, self.errors)
 
@@ -377,7 +377,7 @@ class ImmediateTestResult(unittest._Text
         if self._progress:
             self.stream.write("\r")
         if self._debug:
-            raise err[0], err[1], err[2]
+            raise err[0](err[1]).with_traceback(err[2])
         self._print_traceback("Failure in test %s" % test, err,
                               test, self.failures)
 
@@ -480,11 +480,11 @@ class PathInit:
         kind = functional and "FUNCTIONAL" or "UNIT"
         if libdir:
             extra = os.path.join(self.org_cwd, libdir)
-            print "Running %s tests from %s" % (kind, extra)
+            print("Running %s tests from %s" % (kind, extra))
             self.libdir = extra
             sys.path.insert(0, extra)
         else:
-            print "Running %s tests from %s" % (kind, self.cwd)
+            print("Running %s tests from %s" % (kind, self.cwd))
         # Make sure functional tests find ftesting.zcml
         if functional:
             config_file = 'ftesting.zcml'
@@ -492,7 +492,7 @@ class PathInit:
                 # We chdired into build, so ftesting.zcml is in the
                 # parent directory
                 config_file = os.path.join('..', 'ftesting.zcml')
-            print "Parsing %s" % config_file
+            print("Parsing %s" % config_file)
             from zope.app.tests.functional import FunctionalTestSetup
             FunctionalTestSetup(config_file)
 
@@ -530,7 +530,7 @@ class TestFileFinder:
         if not "__init__.py" in files:
             if not files or files == ["CVS"]:
                 return
-            print "not a package", dir
+            print("not a package", dir)
             return
 
         # Put matching files in matches.  If matches is non-empty,
@@ -549,9 +549,9 @@ class TestFileFinder:
             __import__(pkg)
         # We specifically do not want to catch ImportError since that's useful
         # information to know when running the tests.
-        except RuntimeError, e:
+        except RuntimeError as e:
             if VERBOSE:
-                print "skipping %s because: %s" % (pkg, e)
+                print("skipping %s because: %s" % (pkg, e))
             return
         else:
             self.files.extend(matches)
@@ -698,16 +698,16 @@ class TrackRefs:
         ct = [(type2count[t] - self.type2count.get(t, 0),
                type2all[t] - self.type2all.get(t, 0),
                t)
-              for t in type2count.iterkeys()]
+              for t in type2count.keys()]
         ct.sort()
         ct.reverse()
         printed = False
         for delta1, delta2, t in ct:
             if delta1 or delta2:
                 if not printed:
-                    print "%-55s %8s %8s" % ('', 'insts', 'refs')
+                    print("%-55s %8s %8s" % ('', 'insts', 'refs'))
                     printed = True
-                print "%-55s %8d %8d" % (t, delta1, delta2)
+                print("%-55s %8d %8d" % (t, delta1, delta2))
 
         self.type2count = type2count
         self.type2all = type2all
@@ -729,25 +729,25 @@ def runner(files, test_filter, debug):
         if TIMESFN:
             r.print_times(open(TIMESFN, "w"))
             if VERBOSE:
-                print "Wrote timing data to", TIMESFN
+                print("Wrote timing data to", TIMESFN)
         if TIMETESTS:
             r.print_times(sys.stdout, TIMETESTS)
     except:
         if DEBUGGER:
-            print "%s:" % (sys.exc_info()[0], )
-            print sys.exc_info()[1]
+            print("%s:" % (sys.exc_info()[0], ))
+            print(sys.exc_info()[1])
             pdb.post_mortem(sys.exc_info()[2])
         else:
             raise
 
 def remove_stale_bytecode(arg, dirname, names):
-    names = map(os.path.normcase, names)
+    names = list(map(os.path.normcase, names))
     for name in names:
         if name.endswith(".pyc") or name.endswith(".pyo"):
             srcname = name[:-1]
             if srcname not in names:
                 fullname = os.path.join(dirname, name)
-                print "Removing stale bytecode file", fullname
+                print("Removing stale bytecode file", fullname)
                 os.unlink(fullname)
 
 def main(module_filter, test_filter, libdir):
@@ -773,12 +773,12 @@ def main(module_filter, test_filter, lib
             runner(files, test_filter, DEBUG)
             gc.collect()
             if gc.garbage:
-                print "GARBAGE:", len(gc.garbage), gc.garbage
+                print("GARBAGE:", len(gc.garbage), gc.garbage)
                 return
             if REFCOUNT:
                 prev = rc
                 rc = sys.gettotalrefcount()
-                print "totalrefcount=%-8d change=%-6d" % (rc, rc - prev)
+                print("totalrefcount=%-8d change=%-6d" % (rc, rc - prev))
                 track.update()
     else:
         runner(files, test_filter, DEBUG)
@@ -801,7 +801,7 @@ def configure_logging():
     else:
         logging.basicConfig()
 
-    if os.environ.has_key("LOGGING"):
+    if "LOGGING" in os.environ:
         level = int(os.environ["LOGGING"])
         logging.getLogger().setLevel(level)
 
@@ -865,8 +865,8 @@ def process_args(argv=None):
 
     # import the config file
     if os.path.isfile(config_filename):
-        print 'Configuration file found.'
-        execfile(config_filename, globals())
+        print('Configuration file found.')
+        exec(compile(open(config_filename).read(), config_filename, 'exec'), globals())
 
 
     try:
@@ -884,9 +884,9 @@ def process_args(argv=None):
     # fixme: add the long names
     # fixme: add the extra documentation
     # fixme: test for functional first!
-    except getopt.error, msg:
-        print msg
-        print "Try `python %s -h' for more information." % argv[0]
+    except getopt.error as msg:
+        print(msg)
+        print("Try `python %s -h' for more information." % argv[0])
         sys.exit(2)
 
     for k, v in opts:
@@ -916,13 +916,13 @@ def process_args(argv=None):
             RUN_UNIT = True
             RUN_FUNCTIONAL = True
         elif k in ("-h", "--help"):
-            print __doc__
+            print(__doc__)
             sys.exit(0)
         elif k in ("-g", "--gc-threshold"):
             GC_THRESHOLD = int(v)
         elif k in ("-G", "--gc-option"):
             if not v.startswith("DEBUG_"):
-                print "-G argument must be DEBUG_ flag, not", repr(v)
+                print("-G argument must be DEBUG_ flag, not", repr(v))
                 sys.exit(1)
             GC_FLAGS.append(v)
         elif k in ('-k', '--keepbytecode'):
@@ -968,30 +968,30 @@ def process_args(argv=None):
         import pychecker.checker
 
     if REFCOUNT and not hasattr(sys, "gettotalrefcount"):
-        print "-r ignored, because it needs a debug build of Python"
+        print("-r ignored, because it needs a debug build of Python")
         REFCOUNT = False
 
     if sys.version_info < ( 2,3,2 ):
-        print """\
+        print("""\
         ERROR: Your python version is not supported by Zope3.
-        Zope3 needs Python 2.3.2 or greater. You are running:""" + sys.version
+        Zope3 needs Python 2.3.2 or greater. You are running:""" + sys.version)
         sys.exit(1)
 
     if GC_THRESHOLD is not None:
         if GC_THRESHOLD == 0:
             gc.disable()
-            print "gc disabled"
+            print("gc disabled")
         else:
             gc.set_threshold(GC_THRESHOLD)
-            print "gc threshold:", gc.get_threshold()
+            print("gc threshold:", gc.get_threshold())
 
     if GC_FLAGS:
         val = 0
         for flag in GC_FLAGS:
             v = getattr(gc, flag, None)
             if v is None:
-                print "Unknown gc flag", repr(flag)
-                print gc.set_debug.__doc__
+                print("Unknown gc flag", repr(flag))
+                print(gc.set_debug.__doc__)
                 sys.exit(1)
             val |= v
         gcdebug |= v
@@ -1009,10 +1009,10 @@ def process_args(argv=None):
         if BUILD_INPLACE:
             cmd += "_ext -i"
         if VERBOSE:
-            print cmd
+            print(cmd)
         sts = os.system(cmd)
         if sts:
-            print "Build failed", hex(sts)
+            print("Build failed", hex(sts))
             sys.exit(1)
 
     k = []
@@ -1027,9 +1027,9 @@ def process_args(argv=None):
         if VERBOSE:
             kind = functional and "FUNCTIONAL" or "UNIT"
             if LEVEL == 0:
-                print "Running %s tests at all levels" % kind
+                print("Running %s tests at all levels" % kind)
             else:
-                print "Running %s tests at level %d" % (kind, LEVEL)
+                print("Running %s tests at level %d" % (kind, LEVEL))
 
 # This was to avoid functional tests outside of z3, but this doesn't really
 # work right.
@@ -1073,20 +1073,20 @@ def process_args(argv=None):
                               globals=globals(), locals=vars())
                 r = tracer.results()
                 path = "/tmp/trace.%s" % os.getpid()
-                import cPickle
+                import pickle
                 f = open(path, "wb")
-                cPickle.dump(r, f)
+                pickle.dump(r, f)
                 f.close()
-                print path
+                print(path)
                 r.write_results(show_missing=True,
                                 summary=True, coverdir=coverdir)
             else:
                 bad = main(MODULE_FILTER, TEST_FILTER, LIBDIR)
                 if bad:
                     sys.exit(1)
-        except ImportError, err:
-            print err
-            print sys.path
+        except ImportError as err:
+            print(err)
+            print(sys.path)
             raise
 
 
Index: xen-4.13.0-testing/tools/configure.ac
===================================================================
--- xen-4.13.0-testing.orig/tools/configure.ac
+++ xen-4.13.0-testing/tools/configure.ac
@@ -337,14 +337,14 @@ case "$host_os" in
   freebsd*) ;;
   *) AX_PATH_PROG_OR_FAIL([BASH], [bash]);;
 esac
-AS_IF([test -z "$PYTHON"], [AC_CHECK_PROGS([PYTHON], [python python3 python2], err)])
+AS_IF([test -z "$PYTHON"], [AC_CHECK_PROGS([PYTHON], [python3 python python2], err)])
 AS_IF([test "$PYTHON" = "err"], [AC_MSG_ERROR([No python interpreter found])])
 AS_IF([echo "$PYTHON" | grep -q "^/"], [], [AC_PATH_PROG([PYTHON], [$PYTHON])])
 PYTHONPATH=$PYTHON
 PYTHON=`basename $PYTHONPATH`
 
 AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
-AX_CHECK_PYTHON_VERSION([2], [6])
+AX_CHECK_PYTHON_VERSION([3], [0])
 
 AS_IF([test "$cross_compiling" != yes], [
     AX_CHECK_PYTHON_DEVEL()
Index: xen-4.13.0-testing/tools/libxl/idl.py
===================================================================
--- xen-4.13.0-testing.orig/tools/libxl/idl.py
+++ xen-4.13.0-testing/tools/libxl/idl.py
@@ -271,7 +271,7 @@ class KeyedUnion(Aggregate):
         if not isinstance(keyvar_type, Enumeration):
             raise ValueError
 
-        kv_kwargs = dict([(x.lstrip('keyvar_'),y) for (x,y) in kwargs.items() if x.startswith('keyvar_')])
+        kv_kwargs = dict([(x.lstrip('keyvar_'),y) for (x,y) in list(kwargs.items()) if x.startswith('keyvar_')])
         
         self.keyvar = Field(keyvar_type, keyvar_name, **kv_kwargs)
 
@@ -317,7 +317,7 @@ class Array(Type):
         kwargs.setdefault('json_parse_type', 'JSON_ARRAY')
         Type.__init__(self, namespace=elem_type.namespace, typename=elem_type.rawname + " *", **kwargs)
 
-        lv_kwargs = dict([(x.lstrip('lenvar_'),y) for (x,y) in kwargs.items() if x.startswith('lenvar_')])
+        lv_kwargs = dict([(x.lstrip('lenvar_'),y) for (x,y) in list(kwargs.items()) if x.startswith('lenvar_')])
 
         self.lenvar = Field(integer, lenvar_name, **lv_kwargs)
         self.elem_type = elem_type
@@ -353,7 +353,7 @@ def parse(f):
     globs = {}
     locs = OrderedDict()
 
-    for n,t in globals().items():
+    for n,t in list(globals().items()):
         if isinstance(t, Type):
             globs[n] = t
         elif isinstance(t,type(object)) and issubclass(t, Type):
Index: xen-4.13.0-testing/tools/libxl/gentest.py
===================================================================
--- xen-4.13.0-testing.orig/tools/libxl/gentest.py
+++ xen-4.13.0-testing/tools/libxl/gentest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 from __future__ import print_function
 
Index: xen-4.13.0-testing/tools/libxl/gentypes.py
===================================================================
--- xen-4.13.0-testing.orig/tools/libxl/gentypes.py
+++ xen-4.13.0-testing/tools/libxl/gentypes.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 from __future__ import print_function
 
Index: xen-4.13.0-testing/tools/ocaml/libs/xentoollog/genlevels.py
===================================================================
--- xen-4.13.0-testing.orig/tools/ocaml/libs/xentoollog/genlevels.py
+++ xen-4.13.0-testing/tools/ocaml/libs/xentoollog/genlevels.py
@@ -89,7 +89,7 @@ def gen_c(level):
 def autogen_header(open_comment, close_comment):
     s = open_comment + " AUTO-GENERATED FILE DO NOT EDIT " + close_comment + "\n"
     s += open_comment + " autogenerated by \n"
-    s += reduce(lambda x,y: x + " ", range(len(open_comment + " ")), "")
+    s += reduce(lambda x,y: x + " ", list(range(len(open_comment + " "))), "")
     s += "%s" % " ".join(sys.argv)
     s += "\n " + close_comment + "\n\n"
     return s
Index: xen-4.13.0-testing/tools/include/xen-foreign/mkheader.py
===================================================================
--- xen-4.13.0-testing.orig/tools/include/xen-foreign/mkheader.py
+++ xen-4.13.0-testing/tools/include/xen-foreign/mkheader.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import sys, re;
 from structs import unions, structs, defines;
Index: xen-4.13.0-testing/tools/include/xen-foreign/mkchecker.py
===================================================================
--- xen-4.13.0-testing.orig/tools/include/xen-foreign/mkchecker.py
+++ xen-4.13.0-testing/tools/include/xen-foreign/mkchecker.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import sys;
 from structs import structs, compat_arches;
Index: xen-4.13.0-testing/xen/tools/gen-cpuid.py
===================================================================
--- xen-4.13.0-testing.orig/xen/tools/gen-cpuid.py
+++ xen-4.13.0-testing/xen/tools/gen-cpuid.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 # -*- coding: utf-8 -*-
 
 import sys, os, re
@@ -135,7 +135,7 @@ def crunch_numbers(state):
     common_1d = (FPU, VME, DE, PSE, TSC, MSR, PAE, MCE, CX8, APIC,
                  MTRR, PGE, MCA, CMOV, PAT, PSE36, MMX, FXSR)
 
-    state.known = featureset_to_uint32s(state.names.keys(), nr_entries)
+    state.known = featureset_to_uint32s(list(state.names.keys()), nr_entries)
     state.common_1d = featureset_to_uint32s(common_1d, 1)[0]
     state.special = featureset_to_uint32s(state.raw_special, nr_entries)
     state.pv = featureset_to_uint32s(state.raw_pv, nr_entries)
@@ -317,11 +317,11 @@ def crunch_numbers(state):
 
         state.deep_deps[feat] = seen[1:]
 
-    state.deep_features = featureset_to_uint32s(deps.keys(), nr_entries)
-    state.nr_deep_deps = len(state.deep_deps.keys())
+    state.deep_features = featureset_to_uint32s(list(deps.keys()), nr_entries)
+    state.nr_deep_deps = len(list(state.deep_deps.keys()))
 
     try:
-        _tmp = state.deep_deps.iteritems()
+        _tmp = state.deep_deps.items()
     except AttributeError:
         _tmp = state.deep_deps.items()
 
@@ -329,10 +329,10 @@ def crunch_numbers(state):
         state.deep_deps[k] = featureset_to_uint32s(v, nr_entries)
 
     # Calculate the bitfield name declarations
-    for word in xrange(nr_entries):
+    for word in range(nr_entries):
 
         names = []
-        for bit in xrange(32):
+        for bit in range(32):
 
             name = state.names.get(word * 32 + bit, "")
 
Index: xen-4.13.0-testing/xen/tools/compat-build-source.py
===================================================================
--- xen-4.13.0-testing.orig/xen/tools/compat-build-source.py
+++ xen-4.13.0-testing/xen/tools/compat-build-source.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import re,sys
 
Index: xen-4.13.0-testing/xen/tools/compat-build-header.py
===================================================================
--- xen-4.13.0-testing.orig/xen/tools/compat-build-header.py
+++ xen-4.13.0-testing/xen/tools/compat-build-header.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import re,sys
 
Index: xen-4.13.0-testing/xen/tools/fig-to-oct.py
===================================================================
--- xen-4.13.0-testing.orig/xen/tools/fig-to-oct.py
+++ xen-4.13.0-testing/xen/tools/fig-to-oct.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 import sys
 
 chars_per_line = 18
Index: xen-4.13.0-testing/tools/misc/xensymoops
===================================================================
--- xen-4.13.0-testing.orig/tools/misc/xensymoops
+++ xen-4.13.0-testing/tools/misc/xensymoops
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 # An oops analyser for Xen
 # Usage: xensymoops path-to-xen.s < oops-message
@@ -43,12 +43,12 @@ def read_oops():
     return (eip_addr, stack_addresses)
 
 def usage():
-    print >> sys.stderr, """Usage: %s path-to-asm < oops-msg
+    print("""Usage: %s path-to-asm < oops-msg
     The oops message should be fed to the standard input.  The
     command-line argument specifies the path to the Xen assembly dump
     produced by \"make debug\".  The location of EIP and the backtrace
     will be output to standard output.
-    """ % sys.argv[0]
+    """ % sys.argv[0], file=sys.stderr)
     sys.exit()
 
 ##### main
@@ -99,7 +99,7 @@ while True:
 
     # if this address was seen as a potential code address in the backtrace then
     # record it in the backtrace list
-    if stk_addrs.has_key(address):
+    if address in stk_addrs:
         backtrace.append((stk_addrs[address], address, func))
 
     # if this was the address that EIP...
@@ -107,12 +107,12 @@ while True:
         eip_func = func
 
 
-print "EIP %s in function %s" % (eip_addr, eip_func)
-print "Backtrace:"
+print("EIP %s in function %s" % (eip_addr, eip_func))
+print("Backtrace:")
 
 # sorting will order primarily by the first element of each tuple,
 # i.e. the order in the original oops
 backtrace.sort()
 
 for (i, a, f) in backtrace:
-    print "%s in function %s" % ( a, f )
+    print("%s in function %s" % ( a, f ))