[pypy-commit] pypy exctrans: Do sandboxing of os.* replacements at the rtyper level.
rlamy
pypy.commits at gmail.com
Fri Jan 15 13:59:42 EST 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: exctrans
Changeset: r81819:9091a198ba62
Date: 2016-01-15 18:58 +0000
http://bitbucket.org/pypy/pypy/changeset/9091a198ba62/
Log: Do sandboxing of os.* replacements at the rtyper level.
Putting this in getcallable() is hackish but it's the earliest
reasonable place where the function is correctly annotated.
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -29,6 +29,7 @@
from rpython.rtyper.rclass import RootClassRepr
from rpython.tool.pairtype import pair
from rpython.translator.unsimplify import insert_empty_block
+from rpython.translator.sandbox.rsandbox import make_sandbox_trampoline, _annotate
class RPythonTyper(object):
@@ -561,6 +562,17 @@
def getcallable(self, graph):
def getconcretetype(v):
return self.bindingrepr(v).lowleveltype
+ if self.annotator.translator.config.translation.sandbox:
+ try:
+ name = graph.func._sandbox_external_name
+ except AttributeError:
+ pass
+ else:
+ args_s = [v.annotation for v in graph.getargs()]
+ s_result = graph.getreturnvar().annotation
+ sandboxed = make_sandbox_trampoline(name, args_s, s_result)
+ return self.getannmixlevel().delayedfunction(
+ sandboxed, args_s, s_result)
return getfunctionptr(graph, getconcretetype)
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
@@ -926,9 +926,6 @@
def need_sandboxing(fnobj):
if hasattr(fnobj, '_safe_not_sandboxed'):
return not fnobj._safe_not_sandboxed
- elif getattr(getattr(fnobj, '_callable', None),
- '_sandbox_external_name', None):
- return True
else:
return "if_external"
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
@@ -131,11 +131,7 @@
trampoline marshals its input arguments, dumps them to STDOUT,
and waits for an answer on STDIN.
"""
- if getattr(getattr(fnobj, '_callable', None),
- '_sandbox_external_name', None):
- fnname = fnobj._callable._sandbox_external_name
- else:
- fnname = fnobj._name
+ fnname = fnobj._name
if hasattr(fnobj, 'graph'):
graph = fnobj.graph
args_s = [v.annotation for v in graph.getargs()]
More information about the pypy-commit
mailing list