Permalink
Browse files

Merge branch 'master' of git@github.com:haypo/pysandbox

  • Loading branch information...
2 parents 8b374d5 + 1c850c6 commit b84c20fdb35febdd94227a63de117996f4c60745 Victor Stinner committed Sep 27, 2010
Showing with 18 additions and 3 deletions.
  1. +1 −1 sandbox/proxy.py
  2. 0 sandbox/test/{test_eval.py → test_execute.py}
  3. +17 −2 sandbox/test/test_proxy.py
View
@@ -280,7 +280,7 @@ def proxy(value):
elif isinstance(value, OBJECT_TYPES):
return createReadOnlyObject(value)
else:
- raise TypeError("Unable to proxy a value of type %s" % type(value))
+ raise SandboxError("Unable to proxy a value of type %s" % type(value))
return proxy
proxy = _proxy()
del _proxy
File renamed without changes.
View
@@ -1,5 +1,5 @@
-from sandbox import HAVE_CSANDBOX, SandboxError
-from sandbox.test import createSandbox, SkipTest
+from sandbox import HAVE_CSANDBOX, Sandbox, SandboxError
+from sandbox.test import createSandbox, createSandboxConfig, SkipTest
def test_object_proxy_read():
class Person:
@@ -91,3 +91,18 @@ def setDict(person):
setDict(person)
assert person.name == "victor"
+def test_proxy_module():
+ def check_proxy_module():
+ from sys import modules
+ try:
+ modules['sys']
+ except SandboxError, err:
+ assert str(err) == "Unable to proxy a value of type <type 'module'>"
+ else:
+ assert False
+
+ config = createSandboxConfig()
+ config.allowModule('sys', 'modules')
+ sandbox = Sandbox(config)
+ sandbox.call(check_proxy_module)
+

0 comments on commit b84c20f

Please sign in to comment.