[Zope-Checkins] CVS: Zope/lib/python/RestrictedPython - Eval.py:1.5 Guards.py:1.8 Limits.py:1.4 MutatingWalker.py:1.6 PrintCollector.py:1.4 RCompile.py:1.3 RCompile_2_1.py:1.3 RestrictionMutator.py:1.10 SafeMapping.py:1.3 SelectCompiler.py:1.4 Utilities.py:1.7 __init__.py:1.5
Martijn Pieters
mj@zope.com
Wed, 14 Aug 2002 17:45:03 -0400
Update of /cvs-repository/Zope/lib/python/RestrictedPython
In directory cvs.zope.org:/tmp/cvs-serv15625
Modified Files:
Eval.py Guards.py Limits.py MutatingWalker.py
PrintCollector.py RCompile.py RCompile_2_1.py
RestrictionMutator.py SafeMapping.py SelectCompiler.py
Utilities.py __init__.py
Log Message:
Clean up indentation and trailing whitespace.
=== Zope/lib/python/RestrictedPython/Eval.py 1.4 => 1.5 ===
--- Zope/lib/python/RestrictedPython/Eval.py:1.4 Wed Nov 28 10:51:11 2001
+++ Zope/lib/python/RestrictedPython/Eval.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
"""Restricted Python Expressions
"""
@@ -84,8 +84,8 @@
i=0
code=co.co_code
l=len(code)
- LOAD_NAME=101
- HAVE_ARGUMENT=90
+ LOAD_NAME=101
+ HAVE_ARGUMENT=90
while(i < l):
c=ord(code[i])
if c==LOAD_NAME:
@@ -119,4 +119,3 @@
def __call__(self, **kw):
return self.eval(kw)
-
=== Zope/lib/python/RestrictedPython/Guards.py 1.7 => 1.8 ===
--- Zope/lib/python/RestrictedPython/Guards.py:1.7 Wed Nov 28 10:51:11 2001
+++ Zope/lib/python/RestrictedPython/Guards.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
from __future__ import nested_scopes
@@ -58,7 +58,7 @@
def __setattr__(self, attr, val):
setattr(write(ob), attr, val)
return Wrapper()
- return guard
+ return guard
def _write_wrapper():
@@ -100,7 +100,7 @@
return ob
# Hand the object to the Wrapper instance, then return the instance.
return Wrapper(ob)
- return guard
+ return guard
full_write_guard = _full_write_guard()
def guarded_setattr(object, name, value):
@@ -110,7 +110,3 @@
def guarded_delattr(object, name):
delattr(full_write_guard(object), name)
safe_builtins['delattr'] = guarded_delattr
-
-
-
-
=== Zope/lib/python/RestrictedPython/Limits.py 1.3 => 1.4 ===
--- Zope/lib/python/RestrictedPython/Limits.py:1.3 Wed Nov 28 10:51:11 2001
+++ Zope/lib/python/RestrictedPython/Limits.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__version__='$Revision$'[11:-2]
@@ -44,4 +44,3 @@
raise TypeError, 'cannot convert string to tuple'
return tuple(seq)
limited_builtins['tuple'] = limited_tuple
-
=== Zope/lib/python/RestrictedPython/MutatingWalker.py 1.5 => 1.6 ===
--- Zope/lib/python/RestrictedPython/MutatingWalker.py:1.5 Fri Dec 21 14:34:47 2001
+++ Zope/lib/python/RestrictedPython/MutatingWalker.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__version__='$Revision$'[11:-2]
@@ -72,4 +72,3 @@
def walk(tree, visitor):
return MutatingWalker(visitor).dispatchNode(tree)
-
=== Zope/lib/python/RestrictedPython/PrintCollector.py 1.3 => 1.4 ===
--- Zope/lib/python/RestrictedPython/PrintCollector.py:1.3 Wed Nov 28 10:51:11 2001
+++ Zope/lib/python/RestrictedPython/PrintCollector.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__version__='$Revision$'[11:-2]
=== Zope/lib/python/RestrictedPython/RCompile.py 1.2 => 1.3 ===
--- Zope/lib/python/RestrictedPython/RCompile.py:1.2 Fri Dec 21 14:34:47 2001
+++ Zope/lib/python/RestrictedPython/RCompile.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
"""Compiles restricted code using the compiler module from the
Python standard library.
@@ -146,4 +146,3 @@
"'eval' or 'single'")
gen.compile()
return gen.getCode()
-
=== Zope/lib/python/RestrictedPython/RCompile_2_1.py 1.2 => 1.3 ===
--- Zope/lib/python/RestrictedPython/RCompile_2_1.py:1.2 Fri Dec 21 14:34:47 2001
+++ Zope/lib/python/RestrictedPython/RCompile_2_1.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__version__='$Revision$'[11:-2]
@@ -56,7 +56,7 @@
if err:
if len(err) > 1:
# Drop the first line of the error and adjust the next two.
- err[1].pop(0)
+ err[1].pop(0)
err[1][0] = 'parameters: %s\n' % err[1][0][10:-8]
err[1][1] = ' ' + err[1][1]
return err
@@ -94,38 +94,38 @@
return gen.getCode(), (), rm.warnings, rm.used_names
if 1:
- def compile_restricted_eval(s, filename='<string>', nested_scopes=1):
- '''Compile a restricted expression.'''
- r = compile_restricted_exec('def f(): return \\\n' + s, filename,
- nested_scopes)
- err = r[1]
- if err:
- if len(err) > 1:
- err.pop(0) # Discard first line of error
- else:
- # Extract the code object representing the function body
- r = (r[0].co_consts[1],) + r[1:]
- return r
+ def compile_restricted_eval(s, filename='<string>', nested_scopes=1):
+ '''Compile a restricted expression.'''
+ r = compile_restricted_exec('def f(): return \\\n' + s, filename,
+ nested_scopes)
+ err = r[1]
+ if err:
+ if len(err) > 1:
+ err.pop(0) # Discard first line of error
+ else:
+ # Extract the code object representing the function body
+ r = (r[0].co_consts[1],) + r[1:]
+ return r
else:
- def compile_restricted_eval(s, filename='<string>'):
- '''Compile a restricted expression.'''
- rm = RestrictionMutator()
- tree, err = tryParsing(s, 'eval')
- if err:
- err[1].pop(0) # Discard first line of error
- return err
- MutatingWalker.walk(tree, rm)
- if rm.errors:
- return None, rm.errors, rm.warnings, rm.used_names
- # XXX No "EvalCodeGenerator" exists
- # so here's a hack that gets around it.
- gen = pycodegen.ModuleCodeGenerator(filename)
- gen.emit('SET_LINENO', 0)
- visitor.walk(tree, gen)
- gen.emit('RETURN_VALUE')
- return gen.getCode(), (), rm.warnings, rm.used_names
+ def compile_restricted_eval(s, filename='<string>'):
+ '''Compile a restricted expression.'''
+ rm = RestrictionMutator()
+ tree, err = tryParsing(s, 'eval')
+ if err:
+ err[1].pop(0) # Discard first line of error
+ return err
+ MutatingWalker.walk(tree, rm)
+ if rm.errors:
+ return None, rm.errors, rm.warnings, rm.used_names
+ # XXX No "EvalCodeGenerator" exists
+ # so here's a hack that gets around it.
+ gen = pycodegen.ModuleCodeGenerator(filename)
+ gen.emit('SET_LINENO', 0)
+ visitor.walk(tree, gen)
+ gen.emit('RETURN_VALUE')
+ return gen.getCode(), (), rm.warnings, rm.used_names
DEBUG = 0
def compile_restricted(source, filename, mode):
=== Zope/lib/python/RestrictedPython/RestrictionMutator.py 1.9 => 1.10 ===
--- Zope/lib/python/RestrictedPython/RestrictionMutator.py:1.9 Fri Dec 21 14:34:47 2001
+++ Zope/lib/python/RestrictedPython/RestrictionMutator.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
'''
RestrictionMutator modifies a tree produced by
@@ -271,4 +271,3 @@
def visitAugAssign(self, node, walker):
node.node.in_aug_assign = 1
return walker.defaultVisitNode(node)
-
=== Zope/lib/python/RestrictedPython/SafeMapping.py 1.2 => 1.3 ===
--- Zope/lib/python/RestrictedPython/SafeMapping.py:1.2 Wed Nov 28 10:51:11 2001
+++ Zope/lib/python/RestrictedPython/SafeMapping.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__doc__='''Read-only Mapping class based on MultiMapping
=== Zope/lib/python/RestrictedPython/SelectCompiler.py 1.3 => 1.4 ===
--- Zope/lib/python/RestrictedPython/SelectCompiler.py:1.3 Sat Dec 22 11:39:05 2001
+++ Zope/lib/python/RestrictedPython/SelectCompiler.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
'''
Compiler selector.
@@ -40,5 +40,3 @@
compile_restricted_function, \
compile_restricted_exec, \
compile_restricted_eval
-
-
=== Zope/lib/python/RestrictedPython/Utilities.py 1.6 => 1.7 ===
--- Zope/lib/python/RestrictedPython/Utilities.py:1.6 Wed Nov 28 10:51:11 2001
+++ Zope/lib/python/RestrictedPython/Utilities.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
__version__='$Revision$'[11:-2]
@@ -65,7 +65,7 @@
if type(i) is tt and len(i)==2: k, v = i
else: k= v = i
if h(k): del d[k]
-
+
for i in with:
if type(i) is tt and len(i)==2: k, v = i
else: k= v = i
=== Zope/lib/python/RestrictedPython/__init__.py 1.4 => 1.5 ===
--- Zope/lib/python/RestrictedPython/__init__.py:1.4 Fri Dec 21 14:34:47 2001
+++ Zope/lib/python/RestrictedPython/__init__.py Wed Aug 14 17:44:31 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
-#
+#
##############################################################################
'''
RestrictedPython package.
@@ -17,4 +17,3 @@
from SelectCompiler import *
from PrintCollector import PrintCollector
-