[Python-checkins] python/dist/src/Python ast.c,1.1.2.67,1.1.2.68

nnorwitz@users.sourceforge.net nnorwitz at users.sourceforge.net
Fri Oct 14 09:49:02 CEST 2005


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25703/Python

Modified Files:
      Tag: ast-branch
	ast.c 
Log Message:
add some notes about a memory problem.  hopefully i am missing something and there is a simple fix

Index: ast.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v
retrieving revision 1.1.2.67
retrieving revision 1.1.2.68
diff -u -d -r1.1.2.67 -r1.1.2.68
--- ast.c	13 Oct 2005 15:42:40 -0000	1.1.2.67
+++ ast.c	14 Oct 2005 07:48:59 -0000	1.1.2.68
@@ -2666,28 +2666,45 @@
             return NULL;
 	return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n));
     }
-	/* check for empty base list */
-	if (TYPE(CHILD(n,3)) == RPAR) {
-		s = ast_for_suite(c, CHILD(n,5));
-		if (!s)
-			return NULL;
-		return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)),NULL,s,LINENO(n));
-	}
+    /* check for empty base list */
+    if (TYPE(CHILD(n,3)) == RPAR) {
+	s = ast_for_suite(c, CHILD(n,5));
+	if (!s)
+		return NULL;
+	return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)),NULL,s,LINENO(n));
+    }
+
     /* else handle the base class list */
     _bases = ast_for_testlist(c, CHILD(n, 3));
     if (!_bases)
         return NULL;
+    /* XXX: I don't think we can set to diff types here, how to free???
+
+	Here's the allocation chain:
+    		Tuple (Python-ast.c:907)
+    		ast_for_testlist (ast.c:1782)
+    		ast_for_classdef (ast.c:2677)
+     */
     if (_bases->kind == Tuple_kind)
 	bases = _bases->v.Tuple.elts;
     else {
 	bases = asdl_seq_new(1);
-	if (!bases)
+	if (!bases) {
+	    /* XXX: free _bases */
             return NULL;
+	}
 	asdl_seq_SET(bases, 0, _bases);
     }
+
     s = ast_for_suite(c, CHILD(n, 6));
     if (!s) {
-        asdl_seq_free(bases);   /* XXX is this right for Tuples??? */
+	/* XXX: I think this free is correct, but needs to change see above */
+        if (_bases->kind == Tuple_kind)
+		free_expr(_bases);
+	else {
+		free_expr(_bases);
+        	asdl_seq_free(bases);
+	}
         return NULL;
     }
     return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), bases, s, LINENO(n));



More information about the Python-checkins mailing list