[Zope-Checkins] CVS: Packages/RestrictedPython - RCompile.py:1.3.68.3

Tres Seaver tseaver at zope.com
Fri Nov 26 13:03:52 EST 2004


Update of /cvs-repository/Packages/RestrictedPython
In directory cvs.zope.org:/tmp/cvs-serv21128/lib/python/RestrictedPython

Modified Files:
      Tag: Zope-2_7-branch
	RCompile.py 
Log Message:
 - Apply fix for collector #945.


=== Packages/RestrictedPython/RCompile.py 1.3.68.2 => 1.3.68.3 ===
--- Packages/RestrictedPython/RCompile.py:1.3.68.2	Thu Jan  8 18:33:56 2004
+++ Packages/RestrictedPython/RCompile.py	Fri Nov 26 13:03:21 2004
@@ -220,12 +220,13 @@
         # Stitch the body code into the function.
         f.code.nodes = body_code.node.nodes
         f.name = self.name
-        # Look for a docstring.
-        stmt1 = f.code.nodes[0]
-        if (isinstance(stmt1, ast.Discard) and
-            isinstance(stmt1.expr, ast.Const) and
-            isinstance(stmt1.expr.value, str)):
-            f.doc = stmt1.expr.value
+        # Look for a docstring, if there are any nodes at all
+        if len(f.code.nodes) > 0:
+            stmt1 = f.code.nodes[0]
+            if (isinstance(stmt1, ast.Discard) and
+                isinstance(stmt1.expr, ast.Const) and
+                isinstance(stmt1.expr.value, str)):
+                f.doc = stmt1.expr.value
         # The caller may specify that certain variables are globals
         # so that they can be referenced before a local assignment.
         # The only known example is the variables context, container,



More information about the Zope-Checkins mailing list