Author: Ronan Lamy <ronan.l...@gmail.com> Branch: exctrans Changeset: r81860:068216680608 Date: 2016-01-19 19:03 +0000 http://bitbucket.org/pypy/pypy/changeset/068216680608/
Log: cleanup diff --git a/rpython/translator/c/node.py b/rpython/translator/c/node.py --- a/rpython/translator/c/node.py +++ b/rpython/translator/c/node.py @@ -800,7 +800,8 @@ comma = '' expr += comma i = expr.find('\n') - if i<0: i = len(expr) + if i < 0: + i = len(expr) expr = '%s\t/* %s */%s' % (expr[:i], decoration, expr[i:]) return expr.split('\n') @@ -871,7 +872,7 @@ while start < len(localnames): # pack the local declarations over as few lines as possible total = lengths[start] + 8 - end = start+1 + end = start + 1 while total + lengths[end] < 77: total += lengths[end] + 1 end += 1 diff --git a/rpython/translator/sandbox/rsandbox.py b/rpython/translator/sandbox/rsandbox.py --- a/rpython/translator/sandbox/rsandbox.py +++ b/rpython/translator/sandbox/rsandbox.py @@ -35,7 +35,8 @@ sandboxsafe=True) -@signature(types.int(), types.ptr(rffi.CCHARP.TO), types.int(), returns=types.none()) +@signature(types.int(), types.ptr(rffi.CCHARP.TO), types.int(), + returns=types.none()) def writeall_not_sandboxed(fd, buf, length): while length > 0: size = rffi.cast(rffi.SIZE_T, length) @@ -83,15 +84,24 @@ return loader def reraise_error(error, loader): - if error == 1: raise OSError(load_int(loader), "external error") - elif error == 2: raise IOError - elif error == 3: raise OverflowError - elif error == 4: raise ValueError - elif error == 5: raise ZeroDivisionError - elif error == 6: raise MemoryError - elif error == 7: raise KeyError - elif error == 8: raise IndexError - else: raise RuntimeError + if error == 1: + raise OSError(load_int(loader), "external error") + elif error == 2: + raise IOError + elif error == 3: + raise OverflowError + elif error == 4: + raise ValueError + elif error == 5: + raise ZeroDivisionError + elif error == 6: + raise MemoryError + elif error == 7: + raise KeyError + elif error == 8: + raise IndexError + else: + raise RuntimeError @signature(types.str(), returns=types.impossible()) @@ -102,7 +112,9 @@ raise RuntimeError(msg) # XXX in RPython, the msg is ignored def make_stub(fnname, msg): + """Build always-raising stub function to replace unsupported external.""" log.WARNING(msg) + def execute(*args): not_implemented_stub(msg) execute.__name__ = 'sandboxed_%s' % (fnname,) @@ -118,31 +130,12 @@ load_int = rmarshal.get_loader(int) def get_sandbox_stub(fnobj, rtyper): - """Build always-raising graph for unsupported external function.""" fnname = fnobj._name args_s, s_result = sig_ll(fnobj) msg = "Not implemented: sandboxing for external function '%s'" % (fnname,) execute = make_stub(fnname, msg) return _annotate(rtyper, execute, args_s, s_result) -def get_external_function_sandbox_graph(fnobj, rtyper): - """Build the graph of a helper trampoline function to be used - in place of real calls to the external function 'fnobj'. The - trampoline marshals its input arguments, dumps them to STDOUT, - and waits for an answer on STDIN. - """ - fnname = fnobj._name - if hasattr(fnobj, 'graph'): - graph = fnobj.graph - args_s = [v.annotation for v in graph.getargs()] - s_result = graph.getreturnvar().annotation - else: - # pure external function - fall back to the annotations - # corresponding to the ll types - args_s, s_result = sig_ll(fnobj) - execute = make_sandbox_trampoline(fnname, args_s, s_result) - return _annotate(rtyper, execute, args_s, s_result) - def make_sandbox_trampoline(fnname, args_s, s_result): """Create a trampoline function with the specified signature. _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit