[Zope-Checkins] CVS: Zope/lib/python/RestrictedPython - MutatingWalker.py:1.2.16.1 RestrictionMutator.py:1.5.2.1
Shane Hathaway
shane@digicool.com
Fri, 21 Dec 2001 14:13:40 -0500
Update of /cvs-repository/Zope/lib/python/RestrictedPython
In directory cvs.zope.org:/tmp/cvs-serv5071
Modified Files:
Tag: Zope-2_4-branch
MutatingWalker.py RestrictionMutator.py
Log Message:
Backported stacksize and other compiler bugfixes.
=== Zope/lib/python/RestrictedPython/MutatingWalker.py 1.2 => 1.2.16.1 ===
self._cache = {}
- def defaultVisitNode(self, node, walker=None):
+ def defaultVisitNode(self, node, walker=None, exclude=None):
for name, child in node.__dict__.items():
+ if exclude is not None and name in exclude:
+ continue
v = self.dispatchObject(child)
if v is not child:
# Replace the node.
=== Zope/lib/python/RestrictedPython/RestrictionMutator.py 1.5 => 1.5.2.1 ===
class RestrictionMutator:
+
def __init__(self):
self.funcinfo = FuncInfo()
self.warnings = []
@@ -185,6 +186,8 @@
'because it starts with "_".' % name)
def prepBody(self, body):
+ """Appends prep code to the beginning of a code suite.
+ """
info = self.funcinfo
if info._print_used or info._printed_used:
# Add code at top for creating _print_target
@@ -206,10 +209,11 @@
self.checkName(node, node.name)
for argname in node.argnames:
self.checkName(node, argname)
+ walker.visitSequence(node.defaults)
former_funcinfo = self.funcinfo
self.funcinfo = FuncInfo()
- node = walker.defaultVisitNode(node)
+ node = walker.defaultVisitNode(node, exclude=('defaults',))
self.prepBody(node.code.nodes)
self.funcinfo = former_funcinfo
return node