[Python-checkins] python/dist/src/Python ast.c,1.1.2.24,1.1.2.25

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
Tue, 01 Apr 2003 20:22:19 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv2380

Modified Files:
      Tag: ast-branch
	ast.c 
Log Message:
Two bugs fixes.

When creating Raise() stmts, get CHILD of ch not n!

When freeing object for ImportFrom, use free() since Python-ast.c uses
malloc().  XXX The asdl_c.py generator should use PyObject_Malloc().

Also add abort() to the default: branches of switches for expr and
stmt.  These cases should be covered.


Index: ast.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v
retrieving revision 1.1.2.24
retrieving revision 1.1.2.25
diff -C2 -d -r1.1.2.24 -r1.1.2.25
*** ast.c	1 Apr 2003 22:17:47 -0000	1.1.2.24
--- ast.c	2 Apr 2003 04:22:16 -0000	1.1.2.25
***************
*** 821,824 ****
--- 821,825 ----
      default:
  	fprintf(stderr, "unhandled expr: %d\n", TYPE(n));
+ 	abort();
  	return NULL;
      }
***************
*** 1004,1018 ****
  	    return Raise(NULL, NULL, NULL, LINENO(n));
  	else if (NCH(ch) == 2)
! 	    return Raise(ast_for_expr(CHILD(n, 1)), NULL, NULL, LINENO(n));
  	else if (NCH(ch) == 4)
! 	    return Raise(ast_for_expr(CHILD(n, 1)),
! 			 ast_for_expr(CHILD(n, 3)),
  			 NULL, LINENO(n));
  	else if (NCH(ch) == 6)
! 	    return Raise(ast_for_expr(CHILD(n, 1)),
! 			 ast_for_expr(CHILD(n, 3)),
! 			 ast_for_expr(CHILD(n, 5)), LINENO(n));
      default:
  	fprintf(stderr, "unexpected flow_stmt: %d\n", TYPE(ch));
  	return NULL;
      }
--- 1005,1020 ----
  	    return Raise(NULL, NULL, NULL, LINENO(n));
  	else if (NCH(ch) == 2)
! 	    return Raise(ast_for_expr(CHILD(ch, 1)), NULL, NULL, LINENO(n));
  	else if (NCH(ch) == 4)
! 	    return Raise(ast_for_expr(CHILD(ch, 1)),
! 			 ast_for_expr(CHILD(ch, 3)),
  			 NULL, LINENO(n));
  	else if (NCH(ch) == 6)
! 	    return Raise(ast_for_expr(CHILD(ch, 1)),
! 			 ast_for_expr(CHILD(ch, 3)),
! 			 ast_for_expr(CHILD(ch, 5)), LINENO(n));
      default:
  	fprintf(stderr, "unexpected flow_stmt: %d\n", TYPE(ch));
+ 	abort();
  	return NULL;
      }
***************
*** 1108,1114 ****
  	    asdl_seq_APPEND(aliases, alias_for_import_name(CHILD(n, i)));
  	import = ImportFrom(mod->name, aliases, LINENO(n));
! 	/* XXX we should probably not be using PyObject_Free directly
! 	       should we use asdl_seq_free?  we need to cast if so */
! 	PyObject_Free(mod);
  	return import;
      }
--- 1110,1114 ----
  	    asdl_seq_APPEND(aliases, alias_for_import_name(CHILD(n, i)));
  	import = ImportFrom(mod->name, aliases, LINENO(n));
! 	free(mod);
  	return import;
      }