[Python-3000-checkins] r55262 - in python/branches/p3yk: Grammar/Grammar Include/Python-ast.h Include/graminit.h Include/opcode.h Lib/test/test_unpack_ex.py Misc/NEWS Modules/parsermodule.c Parser/Python.asdl Python/Python-ast.c Python/ast.c Python/ceval.c Python/compile.c Python/graminit.c Python/symtable.c

georg.brandl python-3000-checkins at python.org
Fri May 11 17:28:52 CEST 2007


Author: georg.brandl
Date: Fri May 11 17:28:41 2007
New Revision: 55262

Added:
   python/branches/p3yk/Lib/test/test_unpack_ex.py
Modified:
   python/branches/p3yk/Grammar/Grammar
   python/branches/p3yk/Include/Python-ast.h
   python/branches/p3yk/Include/graminit.h
   python/branches/p3yk/Include/opcode.h
   python/branches/p3yk/Misc/NEWS
   python/branches/p3yk/Modules/parsermodule.c
   python/branches/p3yk/Parser/Python.asdl
   python/branches/p3yk/Python/Python-ast.c
   python/branches/p3yk/Python/ast.c
   python/branches/p3yk/Python/ceval.c
   python/branches/p3yk/Python/compile.c
   python/branches/p3yk/Python/graminit.c
   python/branches/p3yk/Python/symtable.c
Log:
Commit PEP 3132 implementation.


Modified: python/branches/p3yk/Grammar/Grammar
==============================================================================
--- python/branches/p3yk/Grammar/Grammar	(original)
+++ python/branches/p3yk/Grammar/Grammar	Fri May 11 17:28:41 2007
@@ -89,8 +89,9 @@
 or_test: and_test ('or' and_test)*
 and_test: not_test ('and' not_test)*
 not_test: 'not' not_test | comparison
-comparison: expr (comp_op expr)*
+comparison: star_expr (comp_op star_expr)*
 comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'|'is' 'not'
+star_expr: ['*'] expr
 expr: xor_expr ('|' xor_expr)*
 xor_expr: and_expr ('^' and_expr)*
 and_expr: shift_expr ('&' shift_expr)*
@@ -108,7 +109,7 @@
 subscriptlist: subscript (',' subscript)* [',']
 subscript: test | [test] ':' [test] [sliceop]
 sliceop: ':' [test]
-exprlist: expr (',' expr)* [',']
+exprlist: star_expr (',' star_expr)* [',']
 testlist: test (',' test)* [',']
 dictorsetmaker: ( (test ':' test (',' test ':' test)* [',']) |
                   (test (comp_for | (',' test)* [','])) )

Modified: python/branches/p3yk/Include/Python-ast.h
==============================================================================
--- python/branches/p3yk/Include/Python-ast.h	(original)
+++ python/branches/p3yk/Include/Python-ast.h	Fri May 11 17:28:41 2007
@@ -186,7 +186,8 @@
                   SetComp_kind=9, GeneratorExp_kind=10, Yield_kind=11,
                   Compare_kind=12, Call_kind=13, Num_kind=14, Str_kind=15,
                   Bytes_kind=16, Ellipsis_kind=17, Attribute_kind=18,
-                  Subscript_kind=19, Name_kind=20, List_kind=21, Tuple_kind=22};
+                  Subscript_kind=19, Starred_kind=20, Name_kind=21,
+                  List_kind=22, Tuple_kind=23};
 struct _expr {
         enum _expr_kind kind;
         union {
@@ -284,6 +285,11 @@
                 } Subscript;
                 
                 struct {
+                        expr_ty value;
+                        expr_context_ty ctx;
+                } Starred;
+                
+                struct {
                         identifier id;
                         expr_context_ty ctx;
                 } Name;
@@ -499,6 +505,9 @@
 #define Subscript(a0, a1, a2, a3, a4, a5) _Py_Subscript(a0, a1, a2, a3, a4, a5)
 expr_ty _Py_Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int
                       lineno, int col_offset, PyArena *arena);
+#define Starred(a0, a1, a2, a3, a4) _Py_Starred(a0, a1, a2, a3, a4)
+expr_ty _Py_Starred(expr_ty value, expr_context_ty ctx, int lineno, int
+                    col_offset, PyArena *arena);
 #define Name(a0, a1, a2, a3, a4) _Py_Name(a0, a1, a2, a3, a4)
 expr_ty _Py_Name(identifier id, expr_context_ty ctx, int lineno, int
                  col_offset, PyArena *arena);

Modified: python/branches/p3yk/Include/graminit.h
==============================================================================
--- python/branches/p3yk/Include/graminit.h	(original)
+++ python/branches/p3yk/Include/graminit.h	Fri May 11 17:28:41 2007
@@ -55,29 +55,30 @@
 #define not_test 310
 #define comparison 311
 #define comp_op 312
-#define expr 313
-#define xor_expr 314
-#define and_expr 315
-#define shift_expr 316
-#define arith_expr 317
-#define term 318
-#define factor 319
-#define power 320
-#define atom 321
-#define testlist_comp 322
-#define trailer 323
-#define subscriptlist 324
-#define subscript 325
-#define sliceop 326
-#define exprlist 327
-#define testlist 328
-#define dictorsetmaker 329
-#define classdef 330
-#define arglist 331
-#define argument 332
-#define comp_iter 333
-#define comp_for 334
-#define comp_if 335
-#define testlist1 336
-#define encoding_decl 337
-#define yield_expr 338
+#define star_expr 313
+#define expr 314
+#define xor_expr 315
+#define and_expr 316
+#define shift_expr 317
+#define arith_expr 318
+#define term 319
+#define factor 320
+#define power 321
+#define atom 322
+#define testlist_comp 323
+#define trailer 324
+#define subscriptlist 325
+#define subscript 326
+#define sliceop 327
+#define exprlist 328
+#define testlist 329
+#define dictorsetmaker 330
+#define classdef 331
+#define arglist 332
+#define argument 333
+#define comp_iter 334
+#define comp_for 335
+#define comp_if 336
+#define testlist1 337
+#define encoding_decl 338
+#define yield_expr 339

Modified: python/branches/p3yk/Include/opcode.h
==============================================================================
--- python/branches/p3yk/Include/opcode.h	(original)
+++ python/branches/p3yk/Include/opcode.h	Fri May 11 17:28:41 2007
@@ -85,6 +85,8 @@
 #define DELETE_NAME	91	/* "" */
 #define UNPACK_SEQUENCE	92	/* Number of sequence items */
 #define FOR_ITER	93
+#define UNPACK_EX       94      /* Num items before variable part +
+                                   (Num items after variable part << 8) */
 
 #define STORE_ATTR	95	/* Index in name list */
 #define DELETE_ATTR	96	/* "" */

Added: python/branches/p3yk/Lib/test/test_unpack_ex.py
==============================================================================
--- (empty file)
+++ python/branches/p3yk/Lib/test/test_unpack_ex.py	Fri May 11 17:28:41 2007
@@ -0,0 +1,157 @@
+# Tests for extended unpacking, starred expressions.
+
+doctests = """
+
+Unpack tuple
+
+    >>> t = (1, 2, 3)
+    >>> a, *b, c = t
+    >>> a == 1 and b == [2] and c == 3
+    True
+
+Unpack list
+
+    >>> l = [4, 5, 6]
+    >>> a, *b = l
+    >>> a == 4 and b == [5, 6]
+    True
+
+Unpack implied tuple
+
+    >>> *a, = 7, 8, 9
+    >>> a == [7, 8, 9]
+    True
+
+Unpack string... fun!
+
+    >>> a, *b = 'one'
+    >>> a == 'o' and b == ['n', 'e']
+    True
+
+Unpack long sequence
+
+    >>> a, b, c, *d, e, f, g = range(10)
+    >>> (a, b, c, d, e, f, g) == (0, 1, 2, [3, 4, 5, 6], 7, 8, 9)
+    True
+
+Unpack short sequence
+
+    >>> a, *b, c = (1, 2)
+    >>> a == 1 and c == 2 and b == []
+    True
+
+Unpack generic sequence
+
+    >>> class Seq:
+    ...     def __getitem__(self, i):
+    ...         if i >= 0 and i < 3: return i
+    ...         raise IndexError
+    ...
+    >>> a, *b = Seq()
+    >>> a == 0 and b == [1, 2]
+    True
+
+Unpack in for statement
+
+    >>> for a, *b, c in [(1,2,3), (4,5,6,7)]:
+    ...     print(a, b, c)
+    ...
+    1 [2] 3
+    4 [5, 6] 7
+
+Unpack in list
+
+    >>> [a, *b, c] = range(5)
+    >>> a == 0 and b == [1, 2, 3] and c == 4
+    True
+
+Multiple targets
+
+    >>> a, *b, c = *d, e = range(5)
+    >>> a == 0 and b == [1, 2, 3] and c == 4 and d == [0, 1, 2, 3] and e == 4
+    True
+
+Now for some failures
+
+Unpacking non-sequence
+
+    >>> a, *b = 7
+    Traceback (most recent call last):
+      ...
+    TypeError: 'int' object is not iterable
+
+Unpacking sequence too short
+
+    >>> a, *b, c, d, e = Seq()
+    Traceback (most recent call last):
+      ...
+    ValueError: need more than 3 values to unpack
+
+Unpacking a sequence where the test for too long raises a different kind of
+error
+
+    >>> class BozoError(Exception):
+    ...     pass
+    ...
+    >>> class BadSeq:
+    ...     def __getitem__(self, i):
+    ...         if i >= 0 and i < 3:
+    ...             return i
+    ...         elif i == 3:
+    ...             raise BozoError
+    ...         else:
+    ...             raise IndexError
+    ...
+
+Trigger code while not expecting an IndexError (unpack sequence too long, wrong
+error)
+
+    >>> a, *b, c, d, e = BadSeq()
+    Traceback (most recent call last):
+      ...
+    test.test_unpack_ex.BozoError
+
+Now some general starred expressions (all fail).
+
+    >>> a, *b, c, *d, e = range(10) # doctest:+ELLIPSIS
+    Traceback (most recent call last):
+      ...
+    SyntaxError: two starred expressions in assignment (...)
+
+    >>> [*b, *c] = range(10) # doctest:+ELLIPSIS
+    Traceback (most recent call last):
+      ...
+    SyntaxError: two starred expressions in assignment (...)
+
+    >>> *a = range(10) # doctest:+ELLIPSIS
+    Traceback (most recent call last):
+      ...
+    SyntaxError: starred assignment target must be in a list or tuple (...)
+
+    >>> *a # doctest:+ELLIPSIS
+    Traceback (most recent call last):
+      ...
+    SyntaxError: can use starred expression only as assignment target (...)
+
+    >>> *1 # doctest:+ELLIPSIS
+    Traceback (most recent call last):
+      ...
+    SyntaxError: can use starred expression only as assignment target (...)
+
+    >>> x = *a # doctest:+ELLIPSIS
+    Traceback (most recent call last):
+      ...
+    SyntaxError: can use starred expression only as assignment target (...)
+
+"""
+
+__test__ = {'doctests' : doctests}
+
+def test_main(verbose=False):
+    import sys
+    from test import test_support
+    from test import test_unpack_ex
+    test_support.run_doctest(test_unpack_ex, verbose)
+
+if __name__ == "__main__":
+    test_main(verbose=True)

Modified: python/branches/p3yk/Misc/NEWS
==============================================================================
--- python/branches/p3yk/Misc/NEWS	(original)
+++ python/branches/p3yk/Misc/NEWS	Fri May 11 17:28:41 2007
@@ -26,6 +26,9 @@
 Core and Builtins
 -----------------
 
+- PEP 3132 was accepted. That means that you can do ``a, *b = range(5)``
+  to assign 0 to a and [1, 2, 3, 4] to b.
+
 - range() now returns an iterator rather than a list.  Floats are not allowed.
   xrange() is no longer defined.
 

Modified: python/branches/p3yk/Modules/parsermodule.c
==============================================================================
--- python/branches/p3yk/Modules/parsermodule.c	(original)
+++ python/branches/p3yk/Modules/parsermodule.c	Fri May 11 17:28:41 2007
@@ -867,7 +867,8 @@
 VALIDATER(try);                 VALIDATER(except_clause);
 VALIDATER(test);                VALIDATER(and_test);
 VALIDATER(not_test);            VALIDATER(comparison);
-VALIDATER(comp_op);             VALIDATER(expr);
+VALIDATER(comp_op);             
+VALIDATER(star_expr);           VALIDATER(expr);
 VALIDATER(xor_expr);            VALIDATER(and_expr);
 VALIDATER(shift_expr);          VALIDATER(arith_expr);
 VALIDATER(term);                VALIDATER(factor);
@@ -2094,11 +2095,11 @@
     int nch = NCH(tree);
     int res = (validate_ntype(tree, comparison)
                && is_odd(nch)
-               && validate_expr(CHILD(tree, 0)));
+               && validate_star_expr(CHILD(tree, 0)));
 
     for (pos = 1; res && (pos < nch); pos += 2)
         res = (validate_comp_op(CHILD(tree, pos))
-               && validate_expr(CHILD(tree, pos + 1)));
+               && validate_star_expr(CHILD(tree, pos + 1)));
 
     return (res);
 }
@@ -2156,6 +2157,20 @@
 
 
 static int
+validate_star_expr(node *tree)
+{
+    int res = validate_ntype(tree, star_expr);
+    if (!res) return res;
+    if (NCH(tree) == 2) {
+        return validate_ntype(CHILD(tree, 0), STAR) && \
+               validate_expr(CHILD(tree, 1));
+    } else {
+        return validate_expr(CHILD(tree, 0));
+    }
+}
+
+
+static int
 validate_expr(node *tree)
 {
     int j;
@@ -2745,7 +2760,7 @@
 validate_exprlist(node *tree)
 {
     return (validate_repeating_list(tree, exprlist,
-                                    validate_expr, "exprlist"));
+                                    validate_star_expr, "exprlist"));
 }
 
 

Modified: python/branches/p3yk/Parser/Python.asdl
==============================================================================
--- python/branches/p3yk/Parser/Python.asdl	(original)
+++ python/branches/p3yk/Parser/Python.asdl	Fri May 11 17:28:41 2007
@@ -74,6 +74,7 @@
 	     -- the following expression can appear in assignment context
 	     | Attribute(expr value, identifier attr, expr_context ctx)
 	     | Subscript(expr value, slice slice, expr_context ctx)
+	     | Starred(expr value, expr_context ctx)
 	     | Name(identifier id, expr_context ctx)
 	     | List(expr* elts, expr_context ctx) 
 	     | Tuple(expr* elts, expr_context ctx)

Modified: python/branches/p3yk/Python/Python-ast.c
==============================================================================
--- python/branches/p3yk/Python/Python-ast.c	(original)
+++ python/branches/p3yk/Python/Python-ast.c	Fri May 11 17:28:41 2007
@@ -245,6 +245,11 @@
         "slice",
         "ctx",
 };
+static PyTypeObject *Starred_type;
+static char *Starred_fields[]={
+        "value",
+        "ctx",
+};
 static PyTypeObject *Name_type;
 static char *Name_fields[]={
         "id",
@@ -571,6 +576,8 @@
         if (!Attribute_type) return 0;
         Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3);
         if (!Subscript_type) return 0;
+        Starred_type = make_type("Starred", expr_type, Starred_fields, 2);
+        if (!Starred_type) return 0;
         Name_type = make_type("Name", expr_type, Name_fields, 2);
         if (!Name_type) return 0;
         List_type = make_type("List", expr_type, List_fields, 2);
@@ -1662,6 +1669,32 @@
 }
 
 expr_ty
+Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, PyArena
+        *arena)
+{
+        expr_ty p;
+        if (!value) {
+                PyErr_SetString(PyExc_ValueError,
+                                "field value is required for Starred");
+                return NULL;
+        }
+        if (!ctx) {
+                PyErr_SetString(PyExc_ValueError,
+                                "field ctx is required for Starred");
+                return NULL;
+        }
+        p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+        if (!p)
+                return NULL;
+        p->kind = Starred_kind;
+        p->v.Starred.value = value;
+        p->v.Starred.ctx = ctx;
+        p->lineno = lineno;
+        p->col_offset = col_offset;
+        return p;
+}
+
+expr_ty
 Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena
      *arena)
 {
@@ -2606,6 +2639,20 @@
                         goto failed;
                 Py_DECREF(value);
                 break;
+        case Starred_kind:
+                result = PyType_GenericNew(Starred_type, NULL, NULL);
+                if (!result) goto failed;
+                value = ast2obj_expr(o->v.Starred.value);
+                if (!value) goto failed;
+                if (PyObject_SetAttrString(result, "value", value) == -1)
+                        goto failed;
+                Py_DECREF(value);
+                value = ast2obj_expr_context(o->v.Starred.ctx);
+                if (!value) goto failed;
+                if (PyObject_SetAttrString(result, "ctx", value) == -1)
+                        goto failed;
+                Py_DECREF(value);
+                break;
         case Name_kind:
                 result = PyType_GenericNew(Name_type, NULL, NULL);
                 if (!result) goto failed;
@@ -3180,6 +3227,8 @@
             0) return;
         if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) <
             0) return;
+        if (PyDict_SetItemString(d, "Starred", (PyObject*)Starred_type) < 0)
+            return;
         if (PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return;
         if (PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return;
         if (PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return;

Modified: python/branches/p3yk/Python/ast.c
==============================================================================
--- python/branches/p3yk/Python/ast.c	(original)
+++ python/branches/p3yk/Python/ast.c	Fri May 11 17:28:41 2007
@@ -355,6 +355,11 @@
         case Subscript_kind:
             e->v.Subscript.ctx = ctx;
             break;
+        case Starred_kind:
+            e->v.Starred.ctx = ctx;
+            if (!set_context(e->v.Starred.value, ctx, n))
+                return 0;
+            break;
         case Name_kind:
             if (ctx == Store &&
                 !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) {
@@ -1664,6 +1669,21 @@
     return e;
 }
 
+static expr_ty
+ast_for_starred(struct compiling *c, const node *n)
+{
+    expr_ty tmp;
+    REQ(n, star_expr);
+
+    tmp = ast_for_expr(c, CHILD(n, 1));
+    if (!tmp)
+        return NULL;
+
+    /* The Load context is changed later. */
+    return Starred(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena);
+}
+
+
 /* Do not name a variable 'expr'!  Will cause a compile error.
 */
 
@@ -1775,6 +1795,11 @@
             }
             break;
 
+        case star_expr:
+            if (TYPE(CHILD(n, 0)) == STAR) {
+                return ast_for_starred(c, n);
+            }
+            /* Fallthrough */
         /* The next five cases all handle BinOps.  The main body of code
            is the same in each case, but the switch turned inside out to
            reuse the code for each type of operator.

Modified: python/branches/p3yk/Python/ceval.c
==============================================================================
--- python/branches/p3yk/Python/ceval.c	(original)
+++ python/branches/p3yk/Python/ceval.c	Fri May 11 17:28:41 2007
@@ -477,7 +477,7 @@
 };
 
 static enum why_code do_raise(PyObject *, PyObject *, PyObject *);
-static int unpack_iterable(PyObject *, int, PyObject **);
+static int unpack_iterable(PyObject *, int, int, PyObject **);
 
 /* for manipulating the thread switch and periodic "stuff" - used to be
    per thread, now just a pair o' globals */
@@ -1656,7 +1656,7 @@
 					Py_INCREF(w);
 					PUSH(w);
 				}
-			} else if (unpack_iterable(v, oparg,
+			} else if (unpack_iterable(v, oparg, -1,
 						 stack_pointer + oparg)) {
 				stack_pointer += oparg;
 			} else {
@@ -1666,6 +1666,21 @@
 			Py_DECREF(v);
 			break;
 
+		case UNPACK_EX:
+		{
+			int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8);
+			v = POP();
+			
+			if (unpack_iterable(v, oparg & 0xFF, oparg >> 8,
+					    stack_pointer + totalargs)) {
+				stack_pointer += totalargs;
+			} else {
+				why = WHY_EXCEPTION;
+			}
+			Py_DECREF(v);
+			break;
+		}
+
 		case STORE_ATTR:
 			w = GETITEM(names, oparg);
 			v = TOP();
@@ -3077,14 +3092,20 @@
 }
 
 /* Iterate v argcnt times and store the results on the stack (via decreasing
-   sp).  Return 1 for success, 0 if error. */
+   sp).  Return 1 for success, 0 if error.
+   
+   If argcntafter == -1, do a simple unpack. If it is >= 0, do an unpack
+   with a variable target.
+*/
 
 static int
-unpack_iterable(PyObject *v, int argcnt, PyObject **sp)
+unpack_iterable(PyObject *v, int argcnt, int argcntafter, PyObject **sp)
 {
-	int i = 0;
+	int i = 0, j = 0;
+	Py_ssize_t ll = 0;
 	PyObject *it;  /* iter(v) */
 	PyObject *w;
+	PyObject *l = NULL; /* variable list */
 
 	assert(v != NULL);
 
@@ -3106,17 +3127,42 @@
 		*--sp = w;
 	}
 
-	/* We better have exhausted the iterator now. */
-	w = PyIter_Next(it);
-	if (w == NULL) {
-		if (PyErr_Occurred())
-			goto Error;
-		Py_DECREF(it);
-		return 1;
+	if (argcntafter == -1) {
+		/* We better have exhausted the iterator now. */
+		w = PyIter_Next(it);
+		if (w == NULL) {
+			if (PyErr_Occurred())
+				goto Error;
+			Py_DECREF(it);
+			return 1;
+		}
+		Py_DECREF(w);
+		PyErr_SetString(PyExc_ValueError, "too many values to unpack");
+		goto Error;
 	}
-	Py_DECREF(w);
-	PyErr_SetString(PyExc_ValueError, "too many values to unpack");
-	/* fall through */
+
+	l = PySequence_List(it);
+	if (l == NULL)
+		goto Error;
+	*--sp = l;
+	i++;
+
+	ll = PyList_GET_SIZE(l);
+	if (ll < argcntafter) {
+		PyErr_Format(PyExc_ValueError, "need more than %d values to unpack",
+			     argcnt + ll);
+		goto Error;
+	}
+
+	/* Pop the "after-variable" args off the list. */
+	for (j = argcntafter; j > 0; j--, i++) {
+		*--sp = PyList_GET_ITEM(l, ll - j);
+	}
+	/* Resize the list. */
+	((PyListObject *)l)->ob_size = ll - argcntafter;
+	Py_DECREF(it);
+	return 1;
+
 Error:
 	for (; i > 0; i--, sp++)
 		Py_DECREF(*sp);

Modified: python/branches/p3yk/Python/compile.c
==============================================================================
--- python/branches/p3yk/Python/compile.c	(original)
+++ python/branches/p3yk/Python/compile.c	Fri May 11 17:28:41 2007
@@ -786,6 +786,8 @@
 			return 0;
 		case UNPACK_SEQUENCE:
 			return oparg-1;
+		case UNPACK_EX:
+			return (oparg&0xFF) + (oparg>>8);
 		case FOR_ITER:
 			return 1;
 
@@ -2617,7 +2619,21 @@
 {
 	int n = asdl_seq_LEN(e->v.List.elts);
 	if (e->v.List.ctx == Store) {
-		ADDOP_I(c, UNPACK_SEQUENCE, n);
+		int i, seen_star = 0;
+		for (i = 0; i < n; i++) {
+			expr_ty elt = asdl_seq_GET(e->v.List.elts, i);
+			if (elt->kind == Starred_kind && !seen_star) {
+				ADDOP_I(c, UNPACK_EX, (i + ((n-i-1) << 8)));
+				seen_star = 1;
+				asdl_seq_SET(e->v.List.elts, i, elt->v.Starred.value);
+			} else if (elt->kind == Starred_kind) {
+				return compiler_error(c,
+					"two starred expressions in assignment");
+			}
+		}
+		if (!seen_star) {
+			ADDOP_I(c, UNPACK_SEQUENCE, n);
+		}
 	}
 	VISIT_SEQ(c, expr, e->v.List.elts);
 	if (e->v.List.ctx == Load) {
@@ -2631,7 +2647,21 @@
 {
 	int n = asdl_seq_LEN(e->v.Tuple.elts);
 	if (e->v.Tuple.ctx == Store) {
-		ADDOP_I(c, UNPACK_SEQUENCE, n);
+		int i, seen_star = 0;
+		for (i = 0; i < n; i++) {
+			expr_ty elt = asdl_seq_GET(e->v.Tuple.elts, i);
+			if (elt->kind == Starred_kind && !seen_star) {
+				ADDOP_I(c, UNPACK_EX, (i + ((n-i-1) << 8)));
+				seen_star = 1;
+				asdl_seq_SET(e->v.Tuple.elts, i, elt->v.Starred.value);
+			} else if (elt->kind == Starred_kind) {
+				return compiler_error(c,
+					"two starred expressions in assignment");
+			}
+		}
+		if (!seen_star) {
+			ADDOP_I(c, UNPACK_SEQUENCE, n);
+		}
 	}
 	VISIT_SEQ(c, expr, e->v.Tuple.elts);
 	if (e->v.Tuple.ctx == Load) {
@@ -3257,6 +3287,18 @@
 			return 0;
 		}
 		break;
+	case Starred_kind:
+		switch (e->v.Starred.ctx) {
+		case Store:
+			/* In all legitimate cases, the Starred node was already replaced
+			 * by compiler_list/compiler_tuple. XXX: is that okay? */
+			return compiler_error(c,
+				"starred assignment target must be in a list or tuple");
+		default:
+			return compiler_error(c, 
+				"can use starred expression only as assignment target");
+		}
+		break;
 	case Name_kind:
 		return compiler_nameop(c, e->v.Name.id, e->v.Name.ctx);
 	/* child nodes of List and Tuple will have expr_context set */

Modified: python/branches/p3yk/Python/graminit.c
==============================================================================
--- python/branches/p3yk/Python/graminit.c	(original)
+++ python/branches/p3yk/Python/graminit.c	Fri May 11 17:28:41 2007
@@ -1184,10 +1184,10 @@
 	{1, arcs_54_2},
 };
 static arc arcs_55_0[1] = {
-	{104, 1},
+	{119, 1},
 };
 static arc arcs_55_1[2] = {
-	{119, 0},
+	{120, 0},
 	{0, 1},
 };
 static state states_55[2] = {
@@ -1195,15 +1195,15 @@
 	{2, arcs_55_1},
 };
 static arc arcs_56_0[9] = {
-	{120, 1},
 	{121, 1},
 	{122, 1},
 	{123, 1},
 	{124, 1},
 	{125, 1},
+	{126, 1},
 	{98, 1},
 	{117, 2},
-	{126, 3},
+	{127, 3},
 };
 static arc arcs_56_1[1] = {
 	{0, 1},
@@ -1221,22 +1221,26 @@
 	{1, arcs_56_2},
 	{2, arcs_56_3},
 };
-static arc arcs_57_0[1] = {
-	{127, 1},
+static arc arcs_57_0[2] = {
+	{29, 1},
+	{104, 2},
 };
-static arc arcs_57_1[2] = {
-	{128, 0},
-	{0, 1},
+static arc arcs_57_1[1] = {
+	{104, 2},
+};
+static arc arcs_57_2[1] = {
+	{0, 2},
 };
-static state states_57[2] = {
-	{1, arcs_57_0},
-	{2, arcs_57_1},
+static state states_57[3] = {
+	{2, arcs_57_0},
+	{1, arcs_57_1},
+	{1, arcs_57_2},
 };
 static arc arcs_58_0[1] = {
-	{129, 1},
+	{128, 1},
 };
 static arc arcs_58_1[2] = {
-	{130, 0},
+	{129, 0},
 	{0, 1},
 };
 static state states_58[2] = {
@@ -1244,10 +1248,10 @@
 	{2, arcs_58_1},
 };
 static arc arcs_59_0[1] = {
-	{131, 1},
+	{130, 1},
 };
 static arc arcs_59_1[2] = {
-	{132, 0},
+	{131, 0},
 	{0, 1},
 };
 static state states_59[2] = {
@@ -1255,23 +1259,22 @@
 	{2, arcs_59_1},
 };
 static arc arcs_60_0[1] = {
-	{133, 1},
+	{132, 1},
 };
-static arc arcs_60_1[3] = {
-	{134, 0},
-	{135, 0},
+static arc arcs_60_1[2] = {
+	{133, 0},
 	{0, 1},
 };
 static state states_60[2] = {
 	{1, arcs_60_0},
-	{3, arcs_60_1},
+	{2, arcs_60_1},
 };
 static arc arcs_61_0[1] = {
-	{136, 1},
+	{134, 1},
 };
 static arc arcs_61_1[3] = {
-	{137, 0},
-	{138, 0},
+	{135, 0},
+	{136, 0},
 	{0, 1},
 };
 static state states_61[2] = {
@@ -1279,247 +1282,243 @@
 	{3, arcs_61_1},
 };
 static arc arcs_62_0[1] = {
-	{139, 1},
+	{137, 1},
+};
+static arc arcs_62_1[3] = {
+	{138, 0},
+	{139, 0},
+	{0, 1},
 };
-static arc arcs_62_1[5] = {
+static state states_62[2] = {
+	{1, arcs_62_0},
+	{3, arcs_62_1},
+};
+static arc arcs_63_0[1] = {
+	{140, 1},
+};
+static arc arcs_63_1[5] = {
 	{29, 0},
-	{140, 0},
 	{141, 0},
 	{142, 0},
+	{143, 0},
 	{0, 1},
 };
-static state states_62[2] = {
-	{1, arcs_62_0},
-	{5, arcs_62_1},
+static state states_63[2] = {
+	{1, arcs_63_0},
+	{5, arcs_63_1},
 };
-static arc arcs_63_0[4] = {
-	{137, 1},
+static arc arcs_64_0[4] = {
 	{138, 1},
-	{143, 1},
-	{144, 2},
+	{139, 1},
+	{144, 1},
+	{145, 2},
 };
-static arc arcs_63_1[1] = {
-	{139, 2},
+static arc arcs_64_1[1] = {
+	{140, 2},
 };
-static arc arcs_63_2[1] = {
+static arc arcs_64_2[1] = {
 	{0, 2},
 };
-static state states_63[3] = {
-	{4, arcs_63_0},
-	{1, arcs_63_1},
-	{1, arcs_63_2},
-};
-static arc arcs_64_0[1] = {
-	{145, 1},
+static state states_64[3] = {
+	{4, arcs_64_0},
+	{1, arcs_64_1},
+	{1, arcs_64_2},
 };
-static arc arcs_64_1[3] = {
+static arc arcs_65_0[1] = {
 	{146, 1},
+};
+static arc arcs_65_1[3] = {
+	{147, 1},
 	{31, 2},
 	{0, 1},
 };
-static arc arcs_64_2[1] = {
-	{139, 3},
+static arc arcs_65_2[1] = {
+	{140, 3},
 };
-static arc arcs_64_3[1] = {
+static arc arcs_65_3[1] = {
 	{0, 3},
 };
-static state states_64[4] = {
-	{1, arcs_64_0},
-	{3, arcs_64_1},
-	{1, arcs_64_2},
-	{1, arcs_64_3},
+static state states_65[4] = {
+	{1, arcs_65_0},
+	{3, arcs_65_1},
+	{1, arcs_65_2},
+	{1, arcs_65_3},
 };
-static arc arcs_65_0[7] = {
+static arc arcs_66_0[7] = {
 	{13, 1},
-	{148, 2},
-	{150, 3},
+	{149, 2},
+	{151, 3},
 	{19, 4},
-	{153, 4},
-	{154, 5},
+	{154, 4},
+	{155, 5},
 	{79, 4},
 };
-static arc arcs_65_1[3] = {
+static arc arcs_66_1[3] = {
 	{48, 6},
-	{147, 6},
+	{148, 6},
 	{15, 4},
 };
-static arc arcs_65_2[2] = {
-	{147, 7},
-	{149, 4},
-};
-static arc arcs_65_3[2] = {
-	{151, 8},
-	{152, 4},
+static arc arcs_66_2[2] = {
+	{148, 7},
+	{150, 4},
+};
+static arc arcs_66_3[2] = {
+	{152, 8},
+	{153, 4},
 };
-static arc arcs_65_4[1] = {
+static arc arcs_66_4[1] = {
 	{0, 4},
 };
-static arc arcs_65_5[2] = {
-	{154, 5},
+static arc arcs_66_5[2] = {
+	{155, 5},
 	{0, 5},
 };
-static arc arcs_65_6[1] = {
+static arc arcs_66_6[1] = {
 	{15, 4},
 };
-static arc arcs_65_7[1] = {
-	{149, 4},
+static arc arcs_66_7[1] = {
+	{150, 4},
 };
-static arc arcs_65_8[1] = {
-	{152, 4},
+static arc arcs_66_8[1] = {
+	{153, 4},
 };
-static state states_65[9] = {
-	{7, arcs_65_0},
-	{3, arcs_65_1},
-	{2, arcs_65_2},
-	{2, arcs_65_3},
-	{1, arcs_65_4},
-	{2, arcs_65_5},
-	{1, arcs_65_6},
-	{1, arcs_65_7},
-	{1, arcs_65_8},
+static state states_66[9] = {
+	{7, arcs_66_0},
+	{3, arcs_66_1},
+	{2, arcs_66_2},
+	{2, arcs_66_3},
+	{1, arcs_66_4},
+	{2, arcs_66_5},
+	{1, arcs_66_6},
+	{1, arcs_66_7},
+	{1, arcs_66_8},
 };
-static arc arcs_66_0[1] = {
+static arc arcs_67_0[1] = {
 	{22, 1},
 };
-static arc arcs_66_1[3] = {
-	{155, 2},
+static arc arcs_67_1[3] = {
+	{156, 2},
 	{28, 3},
 	{0, 1},
 };
-static arc arcs_66_2[1] = {
+static arc arcs_67_2[1] = {
 	{0, 2},
 };
-static arc arcs_66_3[2] = {
+static arc arcs_67_3[2] = {
 	{22, 4},
 	{0, 3},
 };
-static arc arcs_66_4[2] = {
+static arc arcs_67_4[2] = {
 	{28, 3},
 	{0, 4},
 };
-static state states_66[5] = {
-	{1, arcs_66_0},
-	{3, arcs_66_1},
-	{1, arcs_66_2},
-	{2, arcs_66_3},
-	{2, arcs_66_4},
+static state states_67[5] = {
+	{1, arcs_67_0},
+	{3, arcs_67_1},
+	{1, arcs_67_2},
+	{2, arcs_67_3},
+	{2, arcs_67_4},
 };
-static arc arcs_67_0[3] = {
+static arc arcs_68_0[3] = {
 	{13, 1},
-	{148, 2},
+	{149, 2},
 	{78, 3},
 };
-static arc arcs_67_1[2] = {
+static arc arcs_68_1[2] = {
 	{14, 4},
 	{15, 5},
 };
-static arc arcs_67_2[1] = {
-	{156, 6},
+static arc arcs_68_2[1] = {
+	{157, 6},
 };
-static arc arcs_67_3[1] = {
+static arc arcs_68_3[1] = {
 	{19, 5},
 };
-static arc arcs_67_4[1] = {
+static arc arcs_68_4[1] = {
 	{15, 5},
 };
-static arc arcs_67_5[1] = {
+static arc arcs_68_5[1] = {
 	{0, 5},
 };
-static arc arcs_67_6[1] = {
-	{149, 5},
+static arc arcs_68_6[1] = {
+	{150, 5},
 };
-static state states_67[7] = {
-	{3, arcs_67_0},
-	{2, arcs_67_1},
-	{1, arcs_67_2},
-	{1, arcs_67_3},
-	{1, arcs_67_4},
-	{1, arcs_67_5},
-	{1, arcs_67_6},
+static state states_68[7] = {
+	{3, arcs_68_0},
+	{2, arcs_68_1},
+	{1, arcs_68_2},
+	{1, arcs_68_3},
+	{1, arcs_68_4},
+	{1, arcs_68_5},
+	{1, arcs_68_6},
 };
-static arc arcs_68_0[1] = {
-	{157, 1},
+static arc arcs_69_0[1] = {
+	{158, 1},
 };
-static arc arcs_68_1[2] = {
+static arc arcs_69_1[2] = {
 	{28, 2},
 	{0, 1},
 };
-static arc arcs_68_2[2] = {
-	{157, 1},
+static arc arcs_69_2[2] = {
+	{158, 1},
 	{0, 2},
 };
-static state states_68[3] = {
-	{1, arcs_68_0},
-	{2, arcs_68_1},
-	{2, arcs_68_2},
+static state states_69[3] = {
+	{1, arcs_69_0},
+	{2, arcs_69_1},
+	{2, arcs_69_2},
 };
-static arc arcs_69_0[2] = {
+static arc arcs_70_0[2] = {
 	{22, 1},
 	{23, 2},
 };
-static arc arcs_69_1[2] = {
+static arc arcs_70_1[2] = {
 	{23, 2},
 	{0, 1},
 };
-static arc arcs_69_2[3] = {
+static arc arcs_70_2[3] = {
 	{22, 3},
-	{158, 4},
+	{159, 4},
 	{0, 2},
 };
-static arc arcs_69_3[2] = {
-	{158, 4},
+static arc arcs_70_3[2] = {
+	{159, 4},
 	{0, 3},
 };
-static arc arcs_69_4[1] = {
+static arc arcs_70_4[1] = {
 	{0, 4},
 };
-static state states_69[5] = {
-	{2, arcs_69_0},
-	{2, arcs_69_1},
-	{3, arcs_69_2},
-	{2, arcs_69_3},
-	{1, arcs_69_4},
-};
-static arc arcs_70_0[1] = {
-	{23, 1},
-};
-static arc arcs_70_1[2] = {
-	{22, 2},
-	{0, 1},
-};
-static arc arcs_70_2[1] = {
-	{0, 2},
-};
-static state states_70[3] = {
-	{1, arcs_70_0},
+static state states_70[5] = {
+	{2, arcs_70_0},
 	{2, arcs_70_1},
-	{1, arcs_70_2},
+	{3, arcs_70_2},
+	{2, arcs_70_3},
+	{1, arcs_70_4},
 };
 static arc arcs_71_0[1] = {
-	{104, 1},
+	{23, 1},
 };
 static arc arcs_71_1[2] = {
-	{28, 2},
+	{22, 2},
 	{0, 1},
 };
-static arc arcs_71_2[2] = {
-	{104, 1},
+static arc arcs_71_2[1] = {
 	{0, 2},
 };
 static state states_71[3] = {
 	{1, arcs_71_0},
 	{2, arcs_71_1},
-	{2, arcs_71_2},
+	{1, arcs_71_2},
 };
 static arc arcs_72_0[1] = {
-	{22, 1},
+	{119, 1},
 };
 static arc arcs_72_1[2] = {
 	{28, 2},
 	{0, 1},
 };
 static arc arcs_72_2[2] = {
-	{22, 1},
+	{119, 1},
 	{0, 2},
 };
 static state states_72[3] = {
@@ -1530,245 +1529,261 @@
 static arc arcs_73_0[1] = {
 	{22, 1},
 };
-static arc arcs_73_1[4] = {
+static arc arcs_73_1[2] = {
+	{28, 2},
+	{0, 1},
+};
+static arc arcs_73_2[2] = {
+	{22, 1},
+	{0, 2},
+};
+static state states_73[3] = {
+	{1, arcs_73_0},
+	{2, arcs_73_1},
+	{2, arcs_73_2},
+};
+static arc arcs_74_0[1] = {
+	{22, 1},
+};
+static arc arcs_74_1[4] = {
 	{23, 2},
-	{155, 3},
+	{156, 3},
 	{28, 4},
 	{0, 1},
 };
-static arc arcs_73_2[1] = {
+static arc arcs_74_2[1] = {
 	{22, 5},
 };
-static arc arcs_73_3[1] = {
+static arc arcs_74_3[1] = {
 	{0, 3},
 };
-static arc arcs_73_4[2] = {
+static arc arcs_74_4[2] = {
 	{22, 6},
 	{0, 4},
 };
-static arc arcs_73_5[2] = {
+static arc arcs_74_5[2] = {
 	{28, 7},
 	{0, 5},
 };
-static arc arcs_73_6[2] = {
+static arc arcs_74_6[2] = {
 	{28, 4},
 	{0, 6},
 };
-static arc arcs_73_7[2] = {
+static arc arcs_74_7[2] = {
 	{22, 8},
 	{0, 7},
 };
-static arc arcs_73_8[1] = {
+static arc arcs_74_8[1] = {
 	{23, 2},
 };
-static state states_73[9] = {
-	{1, arcs_73_0},
-	{4, arcs_73_1},
-	{1, arcs_73_2},
-	{1, arcs_73_3},
-	{2, arcs_73_4},
-	{2, arcs_73_5},
-	{2, arcs_73_6},
-	{2, arcs_73_7},
-	{1, arcs_73_8},
+static state states_74[9] = {
+	{1, arcs_74_0},
+	{4, arcs_74_1},
+	{1, arcs_74_2},
+	{1, arcs_74_3},
+	{2, arcs_74_4},
+	{2, arcs_74_5},
+	{2, arcs_74_6},
+	{2, arcs_74_7},
+	{1, arcs_74_8},
 };
-static arc arcs_74_0[1] = {
-	{159, 1},
+static arc arcs_75_0[1] = {
+	{160, 1},
 };
-static arc arcs_74_1[1] = {
+static arc arcs_75_1[1] = {
 	{19, 2},
 };
-static arc arcs_74_2[2] = {
+static arc arcs_75_2[2] = {
 	{13, 3},
 	{23, 4},
 };
-static arc arcs_74_3[2] = {
+static arc arcs_75_3[2] = {
 	{14, 5},
 	{15, 6},
 };
-static arc arcs_74_4[1] = {
+static arc arcs_75_4[1] = {
 	{24, 7},
 };
-static arc arcs_74_5[1] = {
+static arc arcs_75_5[1] = {
 	{15, 6},
 };
-static arc arcs_74_6[1] = {
+static arc arcs_75_6[1] = {
 	{23, 4},
 };
-static arc arcs_74_7[1] = {
+static arc arcs_75_7[1] = {
 	{0, 7},
 };
-static state states_74[8] = {
-	{1, arcs_74_0},
-	{1, arcs_74_1},
-	{2, arcs_74_2},
-	{2, arcs_74_3},
-	{1, arcs_74_4},
-	{1, arcs_74_5},
-	{1, arcs_74_6},
-	{1, arcs_74_7},
+static state states_75[8] = {
+	{1, arcs_75_0},
+	{1, arcs_75_1},
+	{2, arcs_75_2},
+	{2, arcs_75_3},
+	{1, arcs_75_4},
+	{1, arcs_75_5},
+	{1, arcs_75_6},
+	{1, arcs_75_7},
 };
-static arc arcs_75_0[3] = {
-	{160, 1},
+static arc arcs_76_0[3] = {
+	{161, 1},
 	{29, 2},
 	{31, 3},
 };
-static arc arcs_75_1[2] = {
+static arc arcs_76_1[2] = {
 	{28, 4},
 	{0, 1},
 };
-static arc arcs_75_2[1] = {
+static arc arcs_76_2[1] = {
 	{22, 5},
 };
-static arc arcs_75_3[1] = {
+static arc arcs_76_3[1] = {
 	{22, 6},
 };
-static arc arcs_75_4[4] = {
-	{160, 1},
+static arc arcs_76_4[4] = {
+	{161, 1},
 	{29, 2},
 	{31, 3},
 	{0, 4},
 };
-static arc arcs_75_5[2] = {
+static arc arcs_76_5[2] = {
 	{28, 7},
 	{0, 5},
 };
-static arc arcs_75_6[1] = {
+static arc arcs_76_6[1] = {
 	{0, 6},
 };
-static arc arcs_75_7[1] = {
+static arc arcs_76_7[1] = {
 	{31, 3},
 };
-static state states_75[8] = {
-	{3, arcs_75_0},
-	{2, arcs_75_1},
-	{1, arcs_75_2},
-	{1, arcs_75_3},
-	{4, arcs_75_4},
-	{2, arcs_75_5},
-	{1, arcs_75_6},
-	{1, arcs_75_7},
+static state states_76[8] = {
+	{3, arcs_76_0},
+	{2, arcs_76_1},
+	{1, arcs_76_2},
+	{1, arcs_76_3},
+	{4, arcs_76_4},
+	{2, arcs_76_5},
+	{1, arcs_76_6},
+	{1, arcs_76_7},
 };
-static arc arcs_76_0[1] = {
+static arc arcs_77_0[1] = {
 	{22, 1},
 };
-static arc arcs_76_1[3] = {
-	{155, 2},
+static arc arcs_77_1[3] = {
+	{156, 2},
 	{27, 3},
 	{0, 1},
 };
-static arc arcs_76_2[1] = {
+static arc arcs_77_2[1] = {
 	{0, 2},
 };
-static arc arcs_76_3[1] = {
+static arc arcs_77_3[1] = {
 	{22, 2},
 };
-static state states_76[4] = {
-	{1, arcs_76_0},
-	{3, arcs_76_1},
-	{1, arcs_76_2},
-	{1, arcs_76_3},
+static state states_77[4] = {
+	{1, arcs_77_0},
+	{3, arcs_77_1},
+	{1, arcs_77_2},
+	{1, arcs_77_3},
+};
+static arc arcs_78_0[2] = {
+	{156, 1},
+	{163, 1},
 };
-static arc arcs_77_0[2] = {
-	{155, 1},
-	{162, 1},
-};
-static arc arcs_77_1[1] = {
+static arc arcs_78_1[1] = {
 	{0, 1},
 };
-static state states_77[2] = {
-	{2, arcs_77_0},
-	{1, arcs_77_1},
+static state states_78[2] = {
+	{2, arcs_78_0},
+	{1, arcs_78_1},
 };
-static arc arcs_78_0[1] = {
+static arc arcs_79_0[1] = {
 	{97, 1},
 };
-static arc arcs_78_1[1] = {
+static arc arcs_79_1[1] = {
 	{62, 2},
 };
-static arc arcs_78_2[1] = {
+static arc arcs_79_2[1] = {
 	{98, 3},
 };
-static arc arcs_78_3[1] = {
+static arc arcs_79_3[1] = {
 	{108, 4},
 };
-static arc arcs_78_4[2] = {
-	{161, 5},
+static arc arcs_79_4[2] = {
+	{162, 5},
 	{0, 4},
 };
-static arc arcs_78_5[1] = {
+static arc arcs_79_5[1] = {
 	{0, 5},
 };
-static state states_78[6] = {
-	{1, arcs_78_0},
-	{1, arcs_78_1},
-	{1, arcs_78_2},
-	{1, arcs_78_3},
-	{2, arcs_78_4},
-	{1, arcs_78_5},
+static state states_79[6] = {
+	{1, arcs_79_0},
+	{1, arcs_79_1},
+	{1, arcs_79_2},
+	{1, arcs_79_3},
+	{2, arcs_79_4},
+	{1, arcs_79_5},
 };
-static arc arcs_79_0[1] = {
+static arc arcs_80_0[1] = {
 	{93, 1},
 };
-static arc arcs_79_1[1] = {
+static arc arcs_80_1[1] = {
 	{110, 2},
 };
-static arc arcs_79_2[2] = {
-	{161, 3},
+static arc arcs_80_2[2] = {
+	{162, 3},
 	{0, 2},
 };
-static arc arcs_79_3[1] = {
+static arc arcs_80_3[1] = {
 	{0, 3},
 };
-static state states_79[4] = {
-	{1, arcs_79_0},
-	{1, arcs_79_1},
-	{2, arcs_79_2},
-	{1, arcs_79_3},
+static state states_80[4] = {
+	{1, arcs_80_0},
+	{1, arcs_80_1},
+	{2, arcs_80_2},
+	{1, arcs_80_3},
 };
-static arc arcs_80_0[1] = {
+static arc arcs_81_0[1] = {
 	{22, 1},
 };
-static arc arcs_80_1[2] = {
+static arc arcs_81_1[2] = {
 	{28, 0},
 	{0, 1},
 };
-static state states_80[2] = {
-	{1, arcs_80_0},
-	{2, arcs_80_1},
+static state states_81[2] = {
+	{1, arcs_81_0},
+	{2, arcs_81_1},
 };
-static arc arcs_81_0[1] = {
+static arc arcs_82_0[1] = {
 	{19, 1},
 };
-static arc arcs_81_1[1] = {
+static arc arcs_82_1[1] = {
 	{0, 1},
 };
-static state states_81[2] = {
-	{1, arcs_81_0},
-	{1, arcs_81_1},
+static state states_82[2] = {
+	{1, arcs_82_0},
+	{1, arcs_82_1},
 };
-static arc arcs_82_0[1] = {
-	{165, 1},
+static arc arcs_83_0[1] = {
+	{166, 1},
 };
-static arc arcs_82_1[2] = {
+static arc arcs_83_1[2] = {
 	{9, 2},
 	{0, 1},
 };
-static arc arcs_82_2[1] = {
+static arc arcs_83_2[1] = {
 	{0, 2},
 };
-static state states_82[3] = {
-	{1, arcs_82_0},
-	{2, arcs_82_1},
-	{1, arcs_82_2},
+static state states_83[3] = {
+	{1, arcs_83_0},
+	{2, arcs_83_1},
+	{1, arcs_83_2},
 };
-static dfa dfas[83] = {
+static dfa dfas[84] = {
 	{256, "single_input", 0, 3, states_0,
-	 "\004\050\014\000\000\000\000\240\340\251\160\040\113\000\041\000\000\206\120\206\040"},
+	 "\004\050\014\040\000\000\000\240\340\251\160\040\113\000\041\000\000\014\241\014\101"},
 	{257, "file_input", 0, 2, states_1,
-	 "\204\050\014\000\000\000\000\240\340\251\160\040\113\000\041\000\000\206\120\206\040"},
+	 "\204\050\014\040\000\000\000\240\340\251\160\040\113\000\041\000\000\014\241\014\101"},
 	{258, "eval_input", 0, 3, states_2,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
 	{259, "decorator", 0, 7, states_3,
 	 "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{260, "decorators", 0, 2, states_4,
@@ -1794,13 +1809,13 @@
 	{270, "vfplist", 0, 3, states_14,
 	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{271, "stmt", 0, 2, states_15,
-	 "\000\050\014\000\000\000\000\240\340\251\160\040\113\000\041\000\000\206\120\206\040"},
+	 "\000\050\014\040\000\000\000\240\340\251\160\040\113\000\041\000\000\014\241\014\101"},
 	{272, "simple_stmt", 0, 4, states_16,
-	 "\000\040\010\000\000\000\000\240\340\251\160\000\000\000\041\000\000\206\120\006\040"},
+	 "\000\040\010\040\000\000\000\240\340\251\160\000\000\000\041\000\000\014\241\014\100"},
 	{273, "small_stmt", 0, 2, states_17,
-	 "\000\040\010\000\000\000\000\240\340\251\160\000\000\000\041\000\000\206\120\006\040"},
+	 "\000\040\010\040\000\000\000\240\340\251\160\000\000\000\041\000\000\014\241\014\100"},
 	{274, "expr_stmt", 0, 6, states_18,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
 	{275, "augassign", 0, 2, states_19,
 	 "\000\000\000\000\000\000\376\037\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{276, "del_stmt", 0, 3, states_20,
@@ -1808,7 +1823,7 @@
 	{277, "pass_stmt", 0, 2, states_21,
 	 "\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{278, "flow_stmt", 0, 2, states_22,
-	 "\000\000\000\000\000\000\000\000\340\001\000\000\000\000\000\000\000\000\000\000\040"},
+	 "\000\000\000\000\000\000\000\000\340\001\000\000\000\000\000\000\000\000\000\000\100"},
 	{279, "break_stmt", 0, 2, states_23,
 	 "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{280, "continue_stmt", 0, 2, states_24,
@@ -1816,7 +1831,7 @@
 	{281, "return_stmt", 0, 3, states_25,
 	 "\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{282, "yield_stmt", 0, 2, states_26,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\040"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"},
 	{283, "raise_stmt", 0, 7, states_27,
 	 "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"},
 	{284, "import_stmt", 0, 2, states_28,
@@ -1842,7 +1857,7 @@
 	{294, "assert_stmt", 0, 5, states_38,
 	 "\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000"},
 	{295, "compound_stmt", 0, 2, states_39,
-	 "\000\010\004\000\000\000\000\000\000\000\000\040\113\000\000\000\000\000\000\200\000"},
+	 "\000\010\004\000\000\000\000\000\000\000\000\040\113\000\000\000\000\000\000\000\001"},
 	{296, "if_stmt", 0, 8, states_40,
 	 "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"},
 	{297, "while_stmt", 0, 8, states_41,
@@ -1858,79 +1873,81 @@
 	{302, "except_clause", 0, 5, states_46,
 	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000"},
 	{303, "suite", 0, 5, states_47,
-	 "\004\040\010\000\000\000\000\240\340\251\160\000\000\000\041\000\000\206\120\006\040"},
+	 "\004\040\010\040\000\000\000\240\340\251\160\000\000\000\041\000\000\014\241\014\100"},
 	{304, "test", 0, 6, states_48,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
 	{305, "test_nocond", 0, 2, states_49,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
 	{306, "lambdef", 0, 5, states_50,
 	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000"},
 	{307, "lambdef_nocond", 0, 5, states_51,
 	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000"},
 	{308, "or_test", 0, 2, states_52,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\040\000\000\206\120\006\000"},
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\040\000\000\014\241\014\000"},
 	{309, "and_test", 0, 2, states_53,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\040\000\000\206\120\006\000"},
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\040\000\000\014\241\014\000"},
 	{310, "not_test", 0, 3, states_54,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\040\000\000\206\120\006\000"},
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\040\000\000\014\241\014\000"},
 	{311, "comparison", 0, 2, states_55,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\006\000"},
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\000\000\000\014\241\014\000"},
 	{312, "comp_op", 0, 4, states_56,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\004\000\040\177\000\000\000\000\000"},
-	{313, "expr", 0, 2, states_57,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\006\000"},
-	{314, "xor_expr", 0, 2, states_58,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\006\000"},
-	{315, "and_expr", 0, 2, states_59,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\006\000"},
-	{316, "shift_expr", 0, 2, states_60,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\006\000"},
-	{317, "arith_expr", 0, 2, states_61,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\006\000"},
-	{318, "term", 0, 2, states_62,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\006\000"},
-	{319, "factor", 0, 3, states_63,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\006\000"},
-	{320, "power", 0, 4, states_64,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\120\006\000"},
-	{321, "atom", 0, 9, states_65,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\120\006\000"},
-	{322, "testlist_comp", 0, 5, states_66,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
-	{323, "trailer", 0, 7, states_67,
-	 "\000\040\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\020\000\000"},
-	{324, "subscriptlist", 0, 3, states_68,
-	 "\000\040\210\000\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
-	{325, "subscript", 0, 5, states_69,
-	 "\000\040\210\000\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
-	{326, "sliceop", 0, 3, states_70,
+	 "\000\000\000\000\000\000\000\000\000\000\000\000\004\000\040\376\000\000\000\000\000"},
+	{313, "star_expr", 0, 3, states_57,
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\000\000\000\014\241\014\000"},
+	{314, "expr", 0, 2, states_58,
+	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\014\241\014\000"},
+	{315, "xor_expr", 0, 2, states_59,
+	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\014\241\014\000"},
+	{316, "and_expr", 0, 2, states_60,
+	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\014\241\014\000"},
+	{317, "shift_expr", 0, 2, states_61,
+	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\014\241\014\000"},
+	{318, "arith_expr", 0, 2, states_62,
+	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\014\241\014\000"},
+	{319, "term", 0, 2, states_63,
+	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\014\241\014\000"},
+	{320, "factor", 0, 3, states_64,
+	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\014\241\014\000"},
+	{321, "power", 0, 4, states_65,
+	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\240\014\000"},
+	{322, "atom", 0, 9, states_66,
+	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\240\014\000"},
+	{323, "testlist_comp", 0, 5, states_67,
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
+	{324, "trailer", 0, 7, states_68,
+	 "\000\040\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\040\000\000"},
+	{325, "subscriptlist", 0, 3, states_69,
+	 "\000\040\210\040\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
+	{326, "subscript", 0, 5, states_70,
+	 "\000\040\210\040\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
+	{327, "sliceop", 0, 3, states_71,
 	 "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{327, "exprlist", 0, 3, states_71,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\000\000\000\206\120\006\000"},
-	{328, "testlist", 0, 3, states_72,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
-	{329, "dictorsetmaker", 0, 9, states_73,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
-	{330, "classdef", 0, 8, states_74,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000"},
-	{331, "arglist", 0, 8, states_75,
-	 "\000\040\010\240\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
-	{332, "argument", 0, 4, states_76,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
-	{333, "comp_iter", 0, 2, states_77,
+	{328, "exprlist", 0, 3, states_72,
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\000\000\000\014\241\014\000"},
+	{329, "testlist", 0, 3, states_73,
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
+	{330, "dictorsetmaker", 0, 9, states_74,
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
+	{331, "classdef", 0, 8, states_75,
+	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"},
+	{332, "arglist", 0, 8, states_76,
+	 "\000\040\010\240\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
+	{333, "argument", 0, 4, states_77,
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
+	{334, "comp_iter", 0, 2, states_78,
 	 "\000\000\000\000\000\000\000\000\000\000\000\040\002\000\000\000\000\000\000\000\000"},
-	{334, "comp_for", 0, 6, states_78,
+	{335, "comp_for", 0, 6, states_79,
 	 "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"},
-	{335, "comp_if", 0, 4, states_79,
+	{336, "comp_if", 0, 4, states_80,
 	 "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"},
-	{336, "testlist1", 0, 2, states_80,
-	 "\000\040\010\000\000\000\000\000\000\200\000\000\000\000\041\000\000\206\120\006\000"},
-	{337, "encoding_decl", 0, 2, states_81,
+	{337, "testlist1", 0, 2, states_81,
+	 "\000\040\010\040\000\000\000\000\000\200\000\000\000\000\041\000\000\014\241\014\000"},
+	{338, "encoding_decl", 0, 2, states_82,
 	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
-	{338, "yield_expr", 0, 3, states_82,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\040"},
+	{339, "yield_expr", 0, 3, states_83,
+	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"},
 };
-static label labels[166] = {
+static label labels[167] = {
 	{0, "EMPTY"},
 	{256, 0},
 	{4, 0},
@@ -1940,12 +1957,12 @@
 	{271, 0},
 	{0, 0},
 	{258, 0},
-	{328, 0},
+	{329, 0},
 	{259, 0},
 	{50, 0},
 	{291, 0},
 	{7, 0},
-	{331, 0},
+	{332, 0},
 	{8, 0},
 	{260, 0},
 	{261, 0},
@@ -1979,7 +1996,7 @@
 	{293, 0},
 	{294, 0},
 	{275, 0},
-	{338, 0},
+	{339, 0},
 	{37, 0},
 	{38, 0},
 	{39, 0},
@@ -1993,7 +2010,7 @@
 	{47, 0},
 	{49, 0},
 	{1, "del"},
-	{327, 0},
+	{328, 0},
 	{1, "pass"},
 	{279, 0},
 	{280, 0},
@@ -2023,7 +2040,7 @@
 	{298, 0},
 	{299, 0},
 	{300, 0},
-	{330, 0},
+	{331, 0},
 	{1, "if"},
 	{1, "elif"},
 	{1, "else"},
@@ -2035,7 +2052,7 @@
 	{1, "finally"},
 	{1, "with"},
 	{301, 0},
-	{313, 0},
+	{314, 0},
 	{1, "except"},
 	{5, 0},
 	{6, 0},
@@ -2050,6 +2067,7 @@
 	{1, "and"},
 	{1, "not"},
 	{311, 0},
+	{313, 0},
 	{312, 0},
 	{20, 0},
 	{21, 0},
@@ -2058,49 +2076,49 @@
 	{30, 0},
 	{29, 0},
 	{1, "is"},
-	{314, 0},
-	{18, 0},
 	{315, 0},
-	{33, 0},
+	{18, 0},
 	{316, 0},
-	{19, 0},
+	{33, 0},
 	{317, 0},
+	{19, 0},
+	{318, 0},
 	{34, 0},
 	{35, 0},
-	{318, 0},
+	{319, 0},
 	{14, 0},
 	{15, 0},
-	{319, 0},
+	{320, 0},
 	{17, 0},
 	{24, 0},
 	{48, 0},
 	{32, 0},
-	{320, 0},
 	{321, 0},
-	{323, 0},
 	{322, 0},
+	{324, 0},
+	{323, 0},
 	{9, 0},
 	{10, 0},
 	{26, 0},
-	{329, 0},
+	{330, 0},
 	{27, 0},
 	{2, 0},
 	{3, 0},
-	{334, 0},
-	{324, 0},
+	{335, 0},
 	{325, 0},
 	{326, 0},
+	{327, 0},
 	{1, "class"},
-	{332, 0},
 	{333, 0},
-	{335, 0},
+	{334, 0},
 	{336, 0},
 	{337, 0},
+	{338, 0},
 	{1, "yield"},
 };
 grammar _PyParser_Grammar = {
-	83,
+	84,
 	dfas,
-	{166, labels},
+	{167, labels},
 	256
 };

Modified: python/branches/p3yk/Python/symtable.c
==============================================================================
--- python/branches/p3yk/Python/symtable.c	(original)
+++ python/branches/p3yk/Python/symtable.c	Fri May 11 17:28:41 2007
@@ -1294,6 +1294,9 @@
 		VISIT(st, expr, e->v.Subscript.value);
 		VISIT(st, slice, e->v.Subscript.slice);
 		break;
+        case Starred_kind:
+		VISIT(st, expr, e->v.Starred.value);
+		break;
         case Name_kind:
 		if (!symtable_add_def(st, e->v.Name.id, 
 				      e->v.Name.ctx == Load ? USE : DEF_LOCAL))


More information about the Python-3000-checkins mailing list