[Zope-Checkins] CVS: Zope2 - restricted_module.py:1.3 testRestrictions.py:1.3

evan@serenade.digicool.com evan@serenade.digicool.com
Mon, 14 May 2001 12:41:38 -0400


Update of /cvs-repository/Zope2/lib/python/RestrictedPython/tests
In directory serenade:/home/evan/Zope/trunk/lib/python/RestrictedPython/tests

Modified Files:
	restricted_module.py testRestrictions.py 
Log Message:
Handle augmented assignment correctly.



--- Updated File restricted_module.py in package Zope2 --
--- restricted_module.py	2001/04/27 20:27:54	1.2
+++ restricted_module.py	2001/05/14 16:41:38	1.3
@@ -34,19 +34,48 @@
 
 def allowed_write(ob):
     ob.writeable = 1
+    ob.writeable += 1
+    [1 for ob.writeable in 1,2]
     ob['safe'] = 2
+    ob['safe'] += 2
+    [1 for ob['safe'] in 1,2]
 
 def denied_getattr(ob):
+    ob.disallowed += 1
     return ob.disallowed
 
 def denied_setattr(ob):
     ob.allowed = -1
 
+def denied_setattr2(ob):
+    ob.allowed += -1
+
+def denied_setattr3(ob):
+    [1 for ob.allowed in 1,2]
+
+def denied_getitem(ob):
+    ob[1]
+
+def denied_getitem2(ob):
+    ob[1] += 1
+    
 def denied_setitem(ob):
     ob['x'] = 2
 
+def denied_setitem2(ob):
+    ob[0] += 2
+
+def denied_setitem3(ob):
+    [1 for ob['x'] in 1,2]
+
 def denied_setslice(ob):
     ob[0:1] = 'a'
+
+def denied_setslice2(ob):
+    ob[0:1] += 'a'
+
+def denied_setslice3(ob):
+    [1 for ob[0:1] in 1,2]
 
 def strange_attribute():
     # If a guard has attributes with names that don't start with an

--- Updated File testRestrictions.py in package Zope2 --
--- testRestrictions.py	2001/04/27 20:27:54	1.2
+++ testRestrictions.py	2001/05/14 16:41:38	1.3
@@ -89,7 +89,7 @@
     def __getitem__(self, idx):
         if idx == 'protected':
             raise AccessDenied
-        elif idx == 0:
+        elif idx == 0 or idx == 'safe':
             return 1
         elif idx == 1:
             return DisallowedObject
@@ -114,7 +114,7 @@
 
 class TestGuard:
     '''A guard class'''
-    def __init__(self, _ob):
+    def __init__(self, _ob, write=None):
         self.__dict__['_ob'] = _ob
 
     # Read guard methods