Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:FrontRunner
xen.11173
build-python3-conversion.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File build-python3-conversion.patch of Package xen.11173
Index: xen-4.10.1-testing/Config.mk =================================================================== --- xen-4.10.1-testing.orig/Config.mk +++ xen-4.10.1-testing/Config.mk @@ -81,7 +81,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.10.1-testing/tools/configure =================================================================== --- xen-4.10.1-testing.orig/tools/configure +++ xen-4.10.1-testing/tools/configure @@ -6880,7 +6880,7 @@ if echo "$PYTHON" | grep -q "^/"; then : PYTHON=`basename $PYTHONPATH` elif test -z "$PYTHON"; then : - PYTHON="python" + PYTHON="python3" else as_fn_error $? "PYTHON specified, but is not an absolute path" "$LINENO" 5 fi @@ -6929,15 +6929,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.3 " >&5 -$as_echo_n "checking for python version >= 2.3 ... " >&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 < (2, 3)"))'` 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.3" "$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; } @@ -7346,7 +7346,7 @@ if test "$cross_compiling" != yes; then ac_previous_cppflags=$CPPFLAGS ac_previous_ldflags=$LDFLAGS ac_python_version=`$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("VERSION")'` + print(distutils.sysconfig.get_config_var(\"VERSION\"))'` # Extract the first word of "$PYTHON-config", so it can be a program name with args. set dummy $PYTHON-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -7391,20 +7391,20 @@ fi if test x"$pyconfig" = x"no"; then : CPPFLAGS="$CFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print "-I" + distutils.sysconfig.get_config_var("INCLUDEPY")'`" + print("-I" + distutils.sysconfig.get_config_var(\"INCLUDEPY\"))'`" CPPFLAGS="$CPPFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("CFLAGS")'`" + print(distutils.sysconfig.get_config_var(\"CFLAGS\"))'`" PYTHON_LIBS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("LIBS")'`" + print(distutils.sysconfig.get_config_var(\"LIBS\"))'`" PYTHON_LIBS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("SYSLIBS")'`" + print(distutils.sysconfig.get_config_var(\"SYSLIBS\"))'`" LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print "-L" + distutils.sysconfig.get_python_lib(plat_specific=1,\ - standard_lib=1) + "/config"'`" + print("-L" + distutils.sysconfig.get_python_lib(plat_specific=1,\ + standard_lib=1) + "/config")'`" LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("LINKFORSHARED")'`" + print(distutils.sysconfig.get_config_var(\"LINKFORSHARED\"))'`" LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("LDFLAGS")'`" + print(distutils.sysconfig.get_config_var(\"LDFLAGS\"))'`" else @@ -7421,7 +7421,6 @@ else as_fn_error $? "Unable to find Python development headers" "$LINENO" 5 fi - as_ac_Lib=`$as_echo "ac_cv_lib_python$ac_python_version''_PyArg_ParseTuple" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PyArg_ParseTuple in -lpython$ac_python_version" >&5 $as_echo_n "checking for PyArg_ParseTuple in -lpython$ac_python_version... " >&6; } Index: xen-4.10.1-testing/tools/python/test.py =================================================================== --- xen-4.10.1-testing.orig/tools/python/test.py +++ xen-4.10.1-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.10.1-testing/tools/configure.ac =================================================================== --- xen-4.10.1-testing.orig/tools/configure.ac +++ xen-4.10.1-testing/tools/configure.ac @@ -322,10 +322,10 @@ esac AS_IF([echo "$PYTHON" | grep -q "^/"], [ PYTHONPATH=$PYTHON PYTHON=`basename $PYTHONPATH` -],[test -z "$PYTHON"], [PYTHON="python"], +],[test -z "$PYTHON"], [PYTHON="python3"], [AC_MSG_ERROR([PYTHON specified, but is not an absolute path])]) AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON]) -AX_CHECK_PYTHON_VERSION([2], [3]) +AX_CHECK_PYTHON_VERSION([3], [0]) AS_IF([test "$cross_compiling" != yes], [ AX_CHECK_PYTHON_DEVEL() Index: xen-4.10.1-testing/m4/python_devel.m4 =================================================================== --- xen-4.10.1-testing.orig/m4/python_devel.m4 +++ xen-4.10.1-testing/m4/python_devel.m4 @@ -2,25 +2,25 @@ AC_DEFUN([AX_CHECK_PYTHON_DEVEL], [ ac_previous_cppflags=$CPPFLAGS ac_previous_ldflags=$LDFLAGS ac_python_version=`$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("VERSION")'` + print(distutils.sysconfig.get_config_var("VERSION"))'` AC_PATH_PROG([pyconfig], [$PYTHON-config], [no]) AS_IF([test x"$pyconfig" = x"no"], [ dnl For those that don't have python-config CPPFLAGS="$CFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print "-I" + distutils.sysconfig.get_config_var("INCLUDEPY")'`" + print("-I" + distutils.sysconfig.get_config_var("INCLUDEPY"))'`" CPPFLAGS="$CPPFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("CFLAGS")'`" + print(distutils.sysconfig.get_config_var("CFLAGS"))'`" PYTHON_LIBS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("LIBS")'`" + print(distutils.sysconfig.get_config_var("LIBS"))'`" PYTHON_LIBS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("SYSLIBS")'`" + print(distutils.sysconfig.get_config_var("SYSLIBS"))'`" LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print "-L" + distutils.sysconfig.get_python_lib(plat_specific=1,\ - standard_lib=1) + "/config"'`" + print("-L" + distutils.sysconfig.get_python_lib(plat_specific=1,\ + standard_lib=1) + "/config")'`" LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("LINKFORSHARED")'`" + print(distutils.sysconfig.get_config_var("LINKFORSHARED"))'`" LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("LDFLAGS")'`" + print(distutils.sysconfig.get_config_var("LDFLAGS"))'`" ], [ dnl If python-config is found use it CPPFLAGS="$CFLAGS `$PYTHON-config --cflags`" @@ -30,9 +30,6 @@ AS_IF([test x"$pyconfig" = x"no"], [ AC_CHECK_HEADER([Python.h], [], [AC_MSG_ERROR([Unable to find Python development headers])],) -AC_CHECK_LIB(python$ac_python_version, PyArg_ParseTuple, [], - [AC_MSG_ERROR([Unable to find a suitable python development library])], - [$PYTHON_LIBS]) CPPFLAGS=$ac_previous_cppflags LDFLAGS=$ac_previous_ldflags ]) Index: xen-4.10.1-testing/tools/libxl/idl.py =================================================================== --- xen-4.10.1-testing.orig/tools/libxl/idl.py +++ xen-4.10.1-testing/tools/libxl/idl.py @@ -11,7 +11,7 @@ DIR_BOTH = 3 _default_namespace = "" def namespace(s): if type(s) != str: - raise TypeError, "Require a string for the default namespace." + raise TypeError("Require a string for the default namespace.") global _default_namespace _default_namespace = s @@ -269,7 +269,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) @@ -315,7 +315,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 @@ -346,12 +346,12 @@ class OrderedDict(dict): return [(x,self[x]) for x in self.__ordered] def parse(f): - print >>sys.stderr, "Parsing %s" % f + print("Parsing %s" % f, file=sys.stderr) 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): @@ -362,11 +362,10 @@ def parse(f): globs[n] = t try: - execfile(f, globs, locs) - except SyntaxError,e: - raise SyntaxError, \ - "Errors were found at line %d while processing %s:\n\t%s"\ - %(e.lineno,f,e.text) + exec(compile(open(f).read(), f, 'exec'), globs, locs) + except SyntaxError as e: + raise SyntaxError("Errors were found at line %d while processing %s:\n\t%s"\ + %(e.lineno,f,e.text)) types = [t for t in locs.ordered_values() if isinstance(t,Type)] Index: xen-4.10.1-testing/tools/libxl/gentest.py =================================================================== --- xen-4.10.1-testing.orig/tools/libxl/gentest.py +++ xen-4.10.1-testing/tools/libxl/gentest.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import sys @@ -86,7 +86,7 @@ def gen_rand_init(ty, v, indent = " " if __name__ == '__main__': if len(sys.argv) < 3: - print >>sys.stderr, "Usage: gentest.py <idl> <implementation>" + print("Usage: gentest.py <idl> <implementation>", file=sys.stderr) sys.exit(1) random.seed(os.getenv('LIBXL_TESTIDL_SEED')) Index: xen-4.10.1-testing/tools/libxl/gentypes.py =================================================================== --- xen-4.10.1-testing.orig/tools/libxl/gentypes.py +++ xen-4.10.1-testing/tools/libxl/gentypes.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import sys import re @@ -576,14 +576,14 @@ def libxl_C_enum_from_string(ty, str, e, if __name__ == '__main__': if len(sys.argv) != 6: - print >>sys.stderr, "Usage: gentypes.py <idl> <header> <header-private> <header-json> <implementation>" + print("Usage: gentypes.py <idl> <header> <header-private> <header-json> <implementation>", file=sys.stderr) sys.exit(1) (_, idlname, header, header_private, header_json, impl) = sys.argv (builtins,types) = idl.parse(idlname) - print "outputting libxl type definitions to %s" % header + print("outputting libxl type definitions to %s" % header) f = open(header, "w") @@ -633,7 +633,7 @@ if __name__ == '__main__': f.write("""#endif /* %s */\n""" % (header_define)) f.close() - print "outputting libxl JSON definitions to %s" % header_json + print("outputting libxl JSON definitions to %s" % header_json) f = open(header_json, "w") @@ -657,7 +657,7 @@ if __name__ == '__main__': f.write("""#endif /* %s */\n""" % header_json_define) f.close() - print "outputting libxl type internal definitions to %s" % header_private + print("outputting libxl type internal definitions to %s" % header_private) f = open(header_private, "w") @@ -683,7 +683,7 @@ if __name__ == '__main__': f.write("""#endif /* %s */\n""" % header_json_define) f.close() - print "outputting libxl type implementations to %s" % impl + print("outputting libxl type implementations to %s" % impl) f = open(impl, "w") f.write(""" Index: xen-4.10.1-testing/tools/ocaml/libs/xl/genwrap.py =================================================================== --- xen-4.10.1-testing.orig/tools/ocaml/libs/xl/genwrap.py +++ xen-4.10.1-testing/tools/ocaml/libs/xl/genwrap.py @@ -1,8 +1,9 @@ -#!/usr/bin/python +#!/usr/bin/python3 import sys,os import idl +from functools import reduce # typename -> ( ocaml_type, c_from_ocaml, ocaml_from_c ) builtins = { @@ -78,7 +79,7 @@ def ocaml_type_of(ty): elif isinstance(ty,idl.Array): return "%s array" % ocaml_type_of(ty.elem_type) elif isinstance(ty,idl.Builtin): - if not builtins.has_key(ty.typename): + if ty.typename not in builtins: raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) typename,_,_ = builtins[ty.typename] if not typename: @@ -251,7 +252,7 @@ def gen_ocaml_ml(ty, interface, indent=" else: s += "\texternal default : ctx -> %sunit -> t = \"stub_libxl_%s_init\"\n" % (union_args, ty.rawname) - if functions.has_key(ty.rawname): + if ty.rawname in functions: for name,args in functions[ty.rawname]: s += "\texternal %s : " % name s += " -> ".join(args) @@ -278,7 +279,7 @@ def c_val(ty, c, o, indent="", parent = else: s += "%s = Int_val(%s);" % (c, o) elif isinstance(ty,idl.Builtin): - if not builtins.has_key(ty.typename): + if ty.typename not in builtins: raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) _,fn,_ = builtins[ty.typename] if not fn: @@ -375,7 +376,7 @@ def ocaml_Val(ty, o, c, indent="", paren else: s += "%s = Val_int(%s);" % (o, c) elif isinstance(ty,idl.Builtin): - if not builtins.has_key(ty.typename): + if ty.typename not in builtins: raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) _,_,fn = builtins[ty.typename] if not fn: @@ -513,14 +514,14 @@ def gen_c_defaults(ty): 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 if __name__ == '__main__': if len(sys.argv) < 4: - print >>sys.stderr, "Usage: genwrap.py <idl> <mli> <ml> <c-inc>" + print("Usage: genwrap.py <idl> <mli> <ml> <c-inc>", file=sys.stderr) sys.exit(1) (_,types) = idl.parse(sys.argv[1]) @@ -533,7 +534,7 @@ if __name__ == '__main__': for t in blacklist: if t not in [ty.rawname for ty in types]: - print "unknown type %s in blacklist" % t + print("unknown type %s in blacklist" % t) types = [ty for ty in types if not ty.rawname in blacklist] @@ -564,7 +565,7 @@ if __name__ == '__main__': cinc.write("\n") cinc.write(gen_Val_ocaml(ty)) cinc.write("\n") - if functions.has_key(ty.rawname): + if ty.rawname in functions: cinc.write(gen_c_stub_prototype(ty, functions[ty.rawname])) cinc.write("\n") if ty.init_fn is not None: Index: xen-4.10.1-testing/tools/ocaml/libs/xentoollog/genlevels.py =================================================================== --- xen-4.10.1-testing.orig/tools/ocaml/libs/xentoollog/genlevels.py +++ xen-4.10.1-testing/tools/ocaml/libs/xentoollog/genlevels.py @@ -1,6 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/python3 import sys +from functools import reduce def read_levels(): f = open('../../../libs/toollog/include/xentoollog.h', 'r') @@ -86,14 +87,14 @@ 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 if __name__ == '__main__': if len(sys.argv) < 3: - print >>sys.stderr, "Usage: genlevels.py <mli> <ml> <c-inc>" + print("Usage: genlevels.py <mli> <ml> <c-inc>", file=sys.stderr) sys.exit(1) levels, olevels = read_levels() Index: xen-4.10.1-testing/tools/include/xen-foreign/mkheader.py =================================================================== --- xen-4.10.1-testing.orig/tools/include/xen-foreign/mkheader.py +++ xen-4.10.1-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; @@ -205,8 +205,8 @@ for struct in structs: output = re.sub("\\b(%s)_t\\b" % struct, "\\1_%s_t" % arch, output); # replace: integer types -integers = inttypes[arch].keys(); -integers.sort(lambda a, b: cmp(len(b),len(a))); +integers = list(inttypes[arch].keys()); +integers.sort(key = len, reverse=True) for type in integers: output = re.sub("\\b%s\\b" % type, inttypes[arch][type], output); Index: xen-4.10.1-testing/tools/include/xen-foreign/mkchecker.py =================================================================== --- xen-4.10.1-testing.orig/tools/include/xen-foreign/mkchecker.py +++ xen-4.10.1-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; @@ -37,7 +37,7 @@ for struct in structs: f.write('\tprintf("%%-25s |", "%s");\n' % struct); for a in archs: s = struct + "_" + a; - if compat_arches.has_key(a): + if a in compat_arches: compat = compat_arches[a] c = struct + "_" + compat; else: Index: xen-4.10.1-testing/xen/tools/gen-cpuid.py =================================================================== --- xen-4.10.1-testing.orig/xen/tools/gen-cpuid.py +++ xen-4.10.1-testing/xen/tools/gen-cpuid.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 # -*- coding: utf-8 -*- import sys, os, re @@ -98,13 +98,13 @@ def parse_definitions(state): def featureset_to_uint32s(fs, nr): """ Represent a featureset as a list of C-compatible uint32_t's """ - bitmap = 0L + bitmap = 0 for f in fs: - bitmap |= 1L << f + bitmap |= 1 << f words = [] while bitmap: - words.append(bitmap & ((1L << 32) - 1)) + words.append(bitmap & ((1 << 32) - 1)) bitmap >>= 32 assert len(words) <= nr @@ -129,7 +129,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) @@ -299,17 +299,17 @@ 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())) - for k, v in state.deep_deps.iteritems(): + for k, v in state.deep_deps.items(): 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, "") @@ -419,7 +419,7 @@ def open_file_or_fd(val, mode, buffering else: return open(val, mode, buffering) - except StandardError, e: + except Exception as e: if fd != -1: raise Fail("Unable to open fd %d: %s: %s" % (fd, e.__class__.__name__, e)) @@ -462,10 +462,10 @@ def main(): if __name__ == "__main__": try: sys.exit(main()) - except Fail, e: - print >>sys.stderr, "%s:" % (sys.argv[0],), e + except Fail as e: + print("%s:" % (sys.argv[0],), e, file=sys.stderr) sys.exit(1) - except SystemExit, e: + except SystemExit as e: sys.exit(e.code) except KeyboardInterrupt: sys.exit(2) Index: xen-4.10.1-testing/xen/tools/compat-build-source.py =================================================================== --- xen-4.10.1-testing.orig/xen/tools/compat-build-source.py +++ xen-4.10.1-testing/xen/tools/compat-build-source.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 import re,sys @@ -26,4 +26,4 @@ for pat in pats: for line in sys.stdin.readlines(): for pat in pats: line = re.sub(pat[0], pat[1], line) - print line.rstrip() + print(line.rstrip()) Index: xen-4.10.1-testing/xen/tools/compat-build-header.py =================================================================== --- xen-4.10.1-testing.orig/xen/tools/compat-build-header.py +++ xen-4.10.1-testing/xen/tools/compat-build-header.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 import re,sys @@ -23,4 +23,4 @@ pats = [ for line in sys.stdin.readlines(): for pat in pats: line = re.subn(pat[0], pat[1], line)[0] - print line.rstrip() + print(line.rstrip()) Index: xen-4.10.1-testing/xen/tools/get-fields.sh =================================================================== --- xen-4.10.1-testing.orig/xen/tools/get-fields.sh +++ xen-4.10.1-testing/xen/tools/get-fields.sh @@ -139,7 +139,7 @@ handle_field () local tag=$(echo "$5" | ${PYTHON} -c ' import re,sys for line in sys.stdin.readlines(): - print re.subn(r"\s*(struct|union)\s+(compat_)?(\w+)\s.*", r"\3", line)[0].rstrip() + print(re.subn(r"\s*(struct|union)\s+(compat_)?(\w+)\s.*", r"\3", line)[0].rstrip()) ') echo " \\" printf %s "${1}XLAT_$tag(&(_d_)->$3, &(_s_)->$3);" Index: xen-4.10.1-testing/xen/xsm/flask/gen-policy.py =================================================================== --- xen-4.10.1-testing.orig/xen/xsm/flask/gen-policy.py +++ xen-4.10.1-testing/xen/xsm/flask/gen-policy.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 import sys policy_size = 0 Index: xen-4.10.1-testing/xen/tools/fig-to-oct.py =================================================================== --- xen-4.10.1-testing.orig/xen/tools/fig-to-oct.py +++ xen-4.10.1-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.10.1-testing/tools/misc/xensymoops =================================================================== --- xen-4.10.1-testing.orig/tools/misc/xensymoops +++ xen-4.10.1-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 ))
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor