From 045e954fc4cca7ce688ebca4dbd8478e414267df Mon Sep 17 00:00:00 2001 From: Egelmex Date: Wed, 24 Apr 2013 19:56:12 +0100 Subject: [PATCH 1/3] fixing dict_keys is not subscriptable. --- tools/kroc/occbuild.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kroc/occbuild.in b/tools/kroc/occbuild.in index 19e61380..cd5352d5 100755 --- a/tools/kroc/occbuild.in +++ b/tools/kroc/occbuild.in @@ -104,7 +104,7 @@ def run_command(cmd): def safe_sorted(l): """Like sorted(), but returns a mutable list.""" - l = l[:] + l = list(l) l.sort() return l From 9b144b86e9d3c717deeebda27300084c4ab1522b Mon Sep 17 00:00:00 2001 From: Egelmex Date: Wed, 24 Apr 2013 21:08:42 +0100 Subject: [PATCH 2/3] fixing up make-header to work with python2 and python3 this was a mechanical fix this could probably be cleaned up. --- runtime/ccsp/utils/make-header.py | 35 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/runtime/ccsp/utils/make-header.py b/runtime/ccsp/utils/make-header.py index 10d20df1..3b60fb10 100755 --- a/runtime/ccsp/utils/make-header.py +++ b/runtime/ccsp/utils/make-header.py @@ -18,7 +18,7 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -import sys, os, re +import sys, os, re, functools prog_name = "make-header.py" @@ -83,13 +83,12 @@ def die(*s): warn(*s) sys.exit(1) -def safe_sorted(list, cmp): +def safe_sorted(lst, comp): try: - return sorted(list, cmp) + return sorted(lst, key=functools.cmp_to_key(comp)) except NameError: - list = list[:] - list.sort(cmp) - return list + lst = list(lst) + return sorted(lst, key=functools.cmp_to_key(comp)) def load_defines(defines, fn): define_re = re.compile(r'^#define\s+(\S+)') @@ -148,12 +147,12 @@ def test_symbol_requirements(defines, calls, symbols): for name, symbol in symbols.items(): unsupported = False - if symbol.has_key("DEPEND"): + if "DEPENDS" in symbol: for define in symbol["DEPEND"]: - unsupported = unsupported or (not defines.has_key(define)) - if symbol.has_key("INCOMPATIBLE"): + unsupported = unsupported or (not define in defines) + if "INCOMPATIBLE" in symbol: for define in symbol["INCOMPATIBLE"]: - unsupported = unsupported or defines.has_key(define) + unsupported = unsupported or (define in defines) if unsupported: for call in symbol["handles"]: calls[call] = symbols["Y_unsupported"] @@ -164,9 +163,9 @@ def compare_symbols(a, b): prio_a = int(symbols[a].get("PRIO", 0)) prio_b = int(symbols[b].get("PRIO", 0)) if prio_a == prio_b: - return cmp(a, b) + return (a > b) - (a < b) else: - return cmp(prio_b, prio_a) + return (prio_b > prio_a) - (prio_b < prio_a) i = 0 for symbol in safe_sorted(symbols.keys(), compare_symbols): @@ -527,18 +526,18 @@ def gen_sparc_cif_stub(f, symbol, inputs, outputs): f.line("/* sparc unsupported */") def output_cif(defines, symbol_list, symbols, fn): - if defines.has_key("TARGET_CPU_386"): + if "TARGET_CPU_386" in defines: arch_header = gen_i386_header arch_generator = gen_i386_cif_stub - elif defines.has_key("TARGET_CPU_MIPS"): + elif "TARGET_CPU_MIPS" in defines: warn("generating CIF stubs for unsupported architecture...") arch_header = gen_mips_header arch_generator = gen_mips_cif_stub - elif defines.has_key("TARGET_CPU_PPC64"): + elif "TARGET_CPU_PPC64" in defines: warn("generating CIF stubs for unsupported architecture...") arch_header = gen_ppc_header arch_generator = gen_ppc64_cif_stub - elif defines.has_key("TARGET_CPU_SPARC"): + elif "TARGET_CPU_SPARC" in defines: warn("generating CIF stubs for unsupported architecture...") arch_header = gen_sparc_header arch_generator = gen_sparc_cif_stub @@ -577,8 +576,8 @@ def main(args): enumerate_symbols(symbols) symbol_list = safe_sorted( - symbols.keys(), - lambda a, b: cmp(symbols[a]["offset"], symbols[b]["offset"]) + symbols.keys(), + lambda a, b: (symbols[a]["offset"] > symbols[b]["offset"]) - (symbols[a]["offset"] < symbols[b]["offset"]) ) if type == "--kitable": From 170e73381102b50064b64853602033d9b119fe91 Mon Sep 17 00:00:00 2001 From: Egelmex Date: Thu, 25 Apr 2013 12:28:03 +0100 Subject: [PATCH 3/3] Another case of string vs byte like stream --- tools/kroc/occbuild.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kroc/occbuild.in b/tools/kroc/occbuild.in index cd5352d5..92a83ee6 100755 --- a/tools/kroc/occbuild.in +++ b/tools/kroc/occbuild.in @@ -488,7 +488,7 @@ class KRoCToolchain(Toolchain): need_mods.append("forall") # Look for all the other modules we need. - full_path = search_path + capture(programs["kroc"] + ["--incpath"]).strip().split(":") + full_path = search_path + capture(programs["kroc"] + ["--incpath"]).strip().split(b":") lib_opts = [] for need in need_mods: fn = find_in_path("%s.module" % need, full_path)