[Zope-Checkins] CVS: Zope2 - restricted_module.py:1.7.2.1 testRestrictions.py:1.8.2.1
shane@digicool.com
shane@digicool.com
Tue, 26 Jun 2001 15:22:40 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/RestrictedPython/tests
In directory korak.digicool.com:/tmp/cvs-serv22998/tests
Modified Files:
Tag: Zope-2_4-branch
restricted_module.py testRestrictions.py
Log Message:
Same as trunk
--- Updated File restricted_module.py in package Zope2 --
--- restricted_module.py 2001/06/22 18:32:48 1.7
+++ restricted_module.py 2001/06/26 19:22:39 1.7.2.1
@@ -1,3 +1,4 @@
+from __future__ import nested_scopes
def print0():
print 'Hello, world!',
@@ -136,4 +137,12 @@
res = res + mapping.get(c, c)
return res
+def nested_scopes_1():
+ # Fails if 'a' is consumed by the first function.
+ a = 1
+ def f1():
+ return a
+ def f2():
+ return a
+ return f1() + f2()
--- Updated File testRestrictions.py in package Zope2 --
--- testRestrictions.py 2001/06/22 18:32:48 1.8
+++ testRestrictions.py 2001/06/26 19:22:39 1.8.2.1
@@ -57,7 +57,7 @@
compile(source, fn, 'exec')
# Now compile it for real
code = compile_restricted(source, fn, 'exec')
- rmodule = {'__builtins__':None}
+ rmodule = {'__builtins__':{'__import__':__import__, 'None':None}}
builtins = getattr(__builtins__, '__dict__', __builtins__)
for name in ('map', 'reduce', 'int', 'pow', 'range', 'filter',
'len', 'chr', 'ord',
@@ -249,6 +249,10 @@
def checkRot13(self):
res = self.execFunc('rot13', 'Zope is k00l')
assert (res == 'Mbcr vf x00y'), res
+
+ def checkNestedScopes1(self):
+ res = self.execFunc('nested_scopes_1')
+ assert (res == 2), res
def checkUnrestrictedEval(self):
expr = RestrictionCapableEval("{'a':[m.pop()]}['a'] + [m[0]]")