[Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.62, 1.1.2.63

nnorwitz at projects.sourceforge.net nnorwitz at projects.sourceforge.net
Sat Jan 24 14:53:19 EST 2004


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

Modified Files:
      Tag: ast-branch
	newcompile.c 
Log Message:
update known bugs, group by symptoms
handle nested tuple arguments to functions
store __module__ when compiling class
fix crash on nested listcomps
increase stackdepth so test_errno passes


Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.62
retrieving revision 1.1.2.63
diff -C2 -d -r1.1.2.62 -r1.1.2.63
*** newcompile.c	23 Jan 2004 04:13:25 -0000	1.1.2.62
--- newcompile.c	24 Jan 2004 19:51:32 -0000	1.1.2.63
***************
*** 16,53 ****
     KNOWN BUGS:
  
!      1:
!        using coding statement, such as in getopt:
         		# -*- coding: iso-8859-1 -*-
!        needs to be implemented (see also Python/ast.c encoding_decl)
! 
!      2:
!        Get this err msg: XXX rd_object called with exception set
!        From Python/marshal.c::PyMarshal_ReadLastObjectFromFile()
!        This looks like it may be related to #1.
! 
!      3:
!        LOAD_NAME is output instead of LOAD_GLOBAL
! 
!      4:
!        line numbers are off a bit (may just need to add calls to set lineno)
! 
!      5:
!        Modules/parsermodule.c:496: warning: implicit declaration 
!                                    of function `PyParser_SimpleParseString'
! 
!      6:
!        compile.h::b_return is only set, never used
! 
!      7:
!        compound arguments cause seg fault (def f5((compound, first), two):)
! 
!      8:
!        exec ... in ... seg faults (exec w/o in works)
  
!      9:
!        vars() doesn't return local variables
  
!      10:
!        problem with cell objects (see test_builtins::test_map)
  */
  
--- 16,47 ----
     KNOWN BUGS:
  
!    Seg Faults:
!      #: using coding statement, such as in getopt:
         		# -*- coding: iso-8859-1 -*-
!         needs to be implemented (see also Python/ast.c encoding_decl)
!      #: exec 'from __future__ import division' seg faults
!         exec generally still has problems
!      #: test_errno fails because stackdepth() isn't implemented (assert'ed)
  
!    Inappropriate Exceptions:
!      #: problem with cell objects (see test_builtins::test_map)
!      #: x = [1] ; x[0] += 1 
!         raises TypeError: object does not support item assignment
!      #: Get this err msg: XXX rd_object called with exception set
!         From Python/marshal.c::PyMarshal_ReadLastObjectFromFile()
!         This looks like it may be related to encoding not being implemented.
  
!    Invalid behaviour:
!      #: vars() doesn't return local variables
!      #: co_names doesn't contain any names
!      #: doc strings at class scope are POPed, not stored
!         In interactive mode, they are printed. :-)
!      #: ref leaks in interpreter when press return on empty line
!      #: yield or return outside a function don't raise a SyntaxError
!      #: LOAD_NAME is output instead of LOAD_GLOBAL
!      #: line numbers are off a bit (may just need to add calls to set lineno)
!      #: Modules/parsermodule.c:496: warning: implicit declaration 
!                                     of function `PyParser_SimpleParseString'
!      #: compile.h::b_return is only set, never used
  */
  
***************
*** 746,750 ****
  	if (!compiler_enter_scope(c, s->v.FunctionDef.name, (void *)s))
  		return 0;
! 	c->u->u_argcount = asdl_seq_LEN(s->v.FunctionDef.args->args);
  	n = asdl_seq_LEN(s->v.FunctionDef.body);
  	for (i = 0; i < n; i++) {
--- 740,755 ----
  	if (!compiler_enter_scope(c, s->v.FunctionDef.name, (void *)s))
  		return 0;
!         /* unpack nested arguments */
!         for (i = 0; i < asdl_seq_LEN(args->args); i++) {
!             expr_ty arg = asdl_seq_GET(args->args, i);
!             if (arg->kind == Tuple_kind) {
!                 PyObject *id = PyString_FromFormat(".%d", i);
!                 if (id == NULL || !compiler_nameop(c, id, Load))
!                     return 0;
!                 VISIT(c, expr, arg);
!             }
!         }
! 
! 	c->u->u_argcount = asdl_seq_LEN(args->args);
  	n = asdl_seq_LEN(s->v.FunctionDef.body);
  	for (i = 0; i < n; i++) {
***************
*** 774,777 ****
--- 779,783 ----
  	int n;
  	PyCodeObject *co;
+         PyObject *str;
  	/* push class name on stack, needed by BUILD_CLASS */
  	ADDOP_O(c, LOAD_CONST, s->v.ClassDef.name, consts);
***************
*** 783,786 ****
--- 789,807 ----
  	if (!compiler_enter_scope(c, s->v.ClassDef.name, (void *)s))
  		return 0;
+         str = PyString_InternFromString("__name__");
+ 	if (!str || !compiler_nameop(c, str, Load)) {
+ 		Py_XDECREF(str);
+ 		return 0;
+         }
+         
+         Py_DECREF(str);
+         str = PyString_InternFromString("__module__");
+ 	if (!str || !compiler_nameop(c, str, Store)) {
+ 		Py_XDECREF(str);
+ 		return 0;
+         }
+         Py_DECREF(str);
+ 
+         /* XXX: doc strings go POP_TOP, instead of STORE_NAME (__doc__) */
  	VISIT_SEQ(c, stmt, s->v.ClassDef.body);
  	ADDOP(c, LOAD_LOCALS);
***************
*** 1537,1541 ****
  			break;
  		case Param:
! 			assert(0); /* impossible */
  		}
  		ADDOP_O(c, op, name, varnames);
--- 1558,1562 ----
  			break;
  		case Param:
!                     assert(0); /* impossible */
  		}
  		ADDOP_O(c, op, name, varnames);
***************
*** 1714,1720 ****
                              expr_ty elt)
  {
  	/* generate code for the iterator, then each of the ifs,
  	   and then write to the element */
! 	
  	listcomp_ty l;
  	int start, anchor, skip, if_cleanup, i, n;
--- 1735,1745 ----
                              expr_ty elt)
  {
+         /* need to capture u_tmp here for nested list comps,
+            u_tmp is set to NULL in compiler_listcomp */
+         PyObject *u_tmp = c->u->u_tmp;
+ 
  	/* generate code for the iterator, then each of the ifs,
  	   and then write to the element */
! 
  	listcomp_ty l;
  	int start, anchor, skip, if_cleanup, i, n;
***************
*** 1752,1756 ****
          /* only append after the last for generator */
          if (gen_index >= asdl_seq_LEN(generators)) {
!             if (!compiler_nameop(c, c->u->u_tmp, Load))
  		return 0;
              VISIT(c, expr, elt);
--- 1777,1781 ----
          /* only append after the last for generator */
          if (gen_index >= asdl_seq_LEN(generators)) {
!             if (!compiler_nameop(c, u_tmp, Load))
  		return 0;
              VISIT(c, expr, elt);
***************
*** 1770,1774 ****
          /* delete the append method added to locals */
  	if (gen_index == 1)
!             if (!compiler_nameop(c, c->u->u_tmp, Del))
  		return 0;
  	
--- 1795,1799 ----
          /* delete the append method added to locals */
  	if (gen_index == 1)
!             if (!compiler_nameop(c, u_tmp, Del))
  		return 0;
  	
***************
*** 1790,1795 ****
  			return 0;
  	}
! 	PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]",
! 		      ++c->u->u_tmpname);
  	tmp = PyString_FromString(tmpname);
  	if (!tmp)
--- 1815,1819 ----
  			return 0;
  	}
! 	PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]", ++c->u->u_tmpname);
  	tmp = PyString_FromString(tmpname);
  	if (!tmp)
***************
*** 2166,2170 ****
  {
  	/* XXX need to do this */
! 	return 100;
  }
  
--- 2190,2194 ----
  {
  	/* XXX need to do this */
! 	return 1000;
  }
  




More information about the Python-checkins mailing list