[Zope-Checkins] CVS: Zope2 - restricted_module.py:1.5 testRestrictions.py:1.6
shane@digicool.com
shane@digicool.com
Fri, 8 Jun 2001 11:42:08 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/RestrictedPython/tests
In directory korak.digicool.com:/tmp/cvs-serv19623/tests
Modified Files:
restricted_module.py testRestrictions.py
Log Message:
Corrected a formerly obscure bug in the compiler module; Python Scripts
revealed it. "print" with output to a stream and a trailing comma needs to
end with a POP_TOP instruction.
--- Updated File restricted_module.py in package Zope2 --
--- restricted_module.py 2001/05/17 21:42:00 1.4
+++ restricted_module.py 2001/06/08 15:42:07 1.5
@@ -13,6 +13,15 @@
print >>x, 'Hello, world!',
return printed
+def printLines():
+ # This failed before Zope 2.4.0a2
+ r = range(3)
+ for n in r:
+ for m in r:
+ print m + n * len(r),
+ print
+ return printed
+
def primes():
# Somewhat obfuscated code on purpose
print filter(None,map(lambda y:y*reduce(lambda x,y:x*y!=0,
--- Updated File testRestrictions.py in package Zope2 --
--- testRestrictions.py 2001/05/23 18:03:00 1.5
+++ testRestrictions.py 2001/06/08 15:42:07 1.6
@@ -169,6 +169,10 @@
res = self.execFunc('print%s' % i)
assert res == 'Hello, world!', res
+ def checkPrintLines(self):
+ res = self.execFunc('printLines')
+ assert res == '0 1 2\n3 4 5\n6 7 8\n', res
+
def checkPrimes(self):
res = self.execFunc('primes')
assert res == '[2, 3, 5, 7, 11, 13, 17, 19]', res