summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-07-30 16:49:37 (GMT)
committerGuido van Rossum <guido@python.org>1996-07-30 16:49:37 (GMT)
commit8861b74445560c078d11ff6800a3ce20a869ea93 (patch)
tree67426f7e9173e2c4a0f0040f1f97ed7c3270dbc2 /Python
parent3ecebf17324b138a9d10ad429c0ad55ab5de1682 (diff)
downloadcpython-8861b74445560c078d11ff6800a3ce20a869ea93.zip
cpython-8861b74445560c078d11ff6800a3ce20a869ea93.tar.gz
cpython-8861b74445560c078d11ff6800a3ce20a869ea93.tar.bz2
Changes for slice and ellipses
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c23
-rw-r--r--Python/ceval.c80
-rw-r--r--Python/compile.c177
-rw-r--r--Python/graminit.c247
-rw-r--r--Python/import.c2
-rw-r--r--Python/marshal.c7
6 files changed, 355 insertions, 181 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 3a3fe56..00e02de 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -879,6 +879,28 @@ builtin_list(self, args)
return NULL;
}
+
+static PyObject *
+builtin_slice(self, args)
+ PyObject *self;
+ PyObject *args;
+{
+ PyObject *start, *stop, *step;
+
+ start = stop = step = NULL;
+
+ if (!PyArg_ParseTuple(args, "O|OO:slice", &start, &stop, &step))
+ return NULL;
+
+ /*This swapping of stop and start is to maintain compatibility with
+ the range builtin.*/
+ if (stop == NULL) {
+ stop = start;
+ start = NULL;
+ }
+ return PySlice_New(start, stop, step);
+}
+
static object *
builtin_locals(self, args)
object *self;
@@ -1514,6 +1536,7 @@ static struct methodlist builtin_methods[] = {
{"repr", builtin_repr, 1},
{"round", builtin_round, 1},
{"setattr", builtin_setattr, 1},
+ {"slice", builtin_slice, 1},
{"str", builtin_str, 1},
{"tuple", builtin_tuple, 1},
{"type", builtin_type, 1},
diff --git a/Python/ceval.c b/Python/ceval.c
index ec26792..d526095 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -87,6 +87,7 @@ static object *apply_subscript PROTO((object *, object *));
static object *loop_subscript PROTO((object *, object *));
static int slice_index PROTO((object *, int, int *));
static object *apply_slice PROTO((object *, object *, object *));
+static object *build_slice PROTO((object *, object *, object *));
static int assign_subscript PROTO((object *, object *, object *));
static int assign_slice PROTO((object *, object *, object *, object *));
static int cmp_exception PROTO((object *, object *));
@@ -187,6 +188,8 @@ restore_thread(x)
thread (the main thread) ever takes things out of the queue.
*/
+static int ticker = 0; /* main loop counter to do periodic things */
+
#define NPENDINGCALLS 32
static struct {
int (*func) PROTO((ANY *));
@@ -215,6 +218,7 @@ Py_AddPendingCall(func, arg)
pendingcalls[i].func = func;
pendingcalls[i].arg = arg;
pendinglast = j;
+ ticker = 0; /* Signal main loop */
busy = 0;
/* XXX End critical section */
return 0;
@@ -225,11 +229,15 @@ Py_MakePendingCalls()
{
static int busy = 0;
#ifdef WITH_THREAD
- if (get_thread_ident() != main_thread)
+ if (get_thread_ident() != main_thread) {
+ ticker = 0; /* We're not done yet */
return 0;
+ }
#endif
- if (busy)
+ if (busy) {
+ ticker = 0; /* We're not done yet */
return 0;
+ }
busy = 1;
for (;;) {
int i;
@@ -243,6 +251,7 @@ Py_MakePendingCalls()
pendingfirst = (i + 1) % NPENDINGCALLS;
if (func(arg) < 0) {
busy = 0;
+ ticker = 0; /* We're not done yet */
return -1;
}
}
@@ -281,6 +290,12 @@ eval_code(co, globals, locals)
/* Interpreter main loop */
+#ifndef MAX_RECURSION_DEPTH
+#define MAX_RECURSION_DEPTH 10000
+#endif
+
+static int recursion_depth = 0;
+
static object *
eval_code2(co, globals, locals,
args, argcount, kws, kwcount, defs, defcount, owner)
@@ -355,6 +370,13 @@ eval_code2(co, globals, locals,
#define SETLOCAL(i, value) do { XDECREF(GETLOCAL(i)); \
GETLOCAL(i) = value; } while (0)
+#ifdef USE_STACKCHECK
+ if (recursion_depth%10 == 0 && PyOS_CheckStack()) {
+ err_setstr(MemoryError, "Stack overflow");
+ return NULL;
+ }
+#endif
+
if (globals == NULL) {
err_setstr(SystemError, "eval_code2: NULL globals");
return NULL;
@@ -514,6 +536,14 @@ eval_code2(co, globals, locals,
}
}
+ if (++recursion_depth > MAX_RECURSION_DEPTH) {
+ --recursion_depth;
+ err_setstr(RuntimeError, "Maximum recursion depth exceeded");
+ current_frame = f->f_back;
+ DECREF(f);
+ return NULL;
+ }
+
next_instr = GETUSTRINGVALUE(f->f_code->co_code);
stack_pointer = f->f_valuestack;
@@ -522,22 +552,23 @@ eval_code2(co, globals, locals,
x = None; /* Not a reference, just anything non-NULL */
for (;;) {
- static int ticker;
-
/* Do periodic things.
Doing this every time through the loop would add
too much overhead (a function call per instruction).
- So we do it only every Nth instruction. */
-
- if (pendingfirst != pendinglast) {
- if (Py_MakePendingCalls() < 0) {
- why = WHY_EXCEPTION;
- goto on_error;
- }
- }
+ So we do it only every Nth instruction.
+
+ The ticker is reset to zero if there are pending
+ calls (see Py_AddPendingCalls() and
+ Py_MakePendingCalls() above). */
if (--ticker < 0) {
ticker = sys_checkinterval;
+ if (pendingfirst != pendinglast) {
+ if (Py_MakePendingCalls() < 0) {
+ why = WHY_EXCEPTION;
+ goto on_error;
+ }
+ }
if (sigcheck()) {
why = WHY_EXCEPTION;
goto on_error;
@@ -1630,7 +1661,22 @@ eval_code2(co, globals, locals,
}
PUSH(x);
break;
-
+
+ case BUILD_SLICE:
+ if (oparg == 3)
+ w = POP();
+ else
+ w = NULL;
+ v = POP();
+ u = POP();
+ x = build_slice(u,v,w);
+ DECREF(u);
+ DECREF(v);
+ XDECREF(w);
+ PUSH(x);
+ break;
+
+
default:
fprintf(stderr,
"XXX lineno: %d, opcode: %d\n",
@@ -1793,6 +1839,7 @@ eval_code2(co, globals, locals,
current_frame = f->f_back;
DECREF(f);
+ --recursion_depth;
return retval;
}
@@ -2549,6 +2596,13 @@ slice_index(v, isize, pi)
}
static object *
+build_slice(u, v, w) /* u:v:w */
+ object *u, *v, *w;
+{
+ return PySlice_New(u,v,w);
+}
+
+static object *
apply_slice(u, v, w) /* return u[v:w] */
object *u, *v, *w;
{
diff --git a/Python/compile.c b/Python/compile.c
index 3299ad9..f20036b 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -47,6 +47,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <ctype.h>
#include <errno.h>
+#define OP_DELETE 0
+#define OP_ASSIGN 1
+#define OP_APPLY 2
+
#define OFF(x) offsetof(codeobject, x)
static struct memberlist code_memberlist[] = {
@@ -821,31 +825,6 @@ com_slice(c, n, op)
}
}
-static void
-com_apply_subscript(c, n)
- struct compiling *c;
- node *n;
-{
- REQ(n, subscript);
- if (TYPE(CHILD(n, 0)) == COLON || (NCH(n) > 1 && TYPE(CHILD(n, 1)) == COLON)) {
- /* It's a slice: [expr] ':' [expr] */
- com_slice(c, n, SLICE);
- }
- else {
- /* It's a list of subscripts */
- if (NCH(n) == 1)
- com_node(c, CHILD(n, 0));
- else {
- int i;
- int len = (NCH(n)+1)/2;
- for (i = 0; i < NCH(n); i += 2)
- com_node(c, CHILD(n, i));
- com_addoparg(c, BUILD_TUPLE, len);
- }
- com_addbyte(c, BINARY_SUBSCR);
- }
-}
-
static int
com_argument(c, n, inkeywords)
struct compiling *c;
@@ -924,6 +903,107 @@ com_select_member(c, n)
}
static void
+com_sliceobj(c, n)
+ struct compiling *c;
+ node *n;
+{
+ int i=0;
+ int ns=2; /* number of slice arguments */
+ int first_missing=0;
+ node *ch;
+
+ /* first argument */
+ if (TYPE(CHILD(n,i)) == COLON) {
+ com_addoparg(c, LOAD_CONST, com_addconst(c, None));
+ i++;
+ }
+ else {
+ com_node(c, CHILD(n,i));
+ i++;
+ REQ(CHILD(n,i),COLON);
+ i++;
+ }
+ /* second argument */
+ if (i < NCH(n) && TYPE(CHILD(n,i)) == test) {
+ com_node(c, CHILD(n,i));
+ i++;
+ }
+ else com_addoparg(c, LOAD_CONST, com_addconst(c, None));
+ /* remaining arguments */
+ for (; i < NCH(n); i++) {
+ ns++;
+ ch=CHILD(n,i);
+ REQ(ch, sliceop);
+ if (NCH(ch) == 1) {
+ /* right argument of ':' missing */
+ com_addoparg(c, LOAD_CONST, com_addconst(c, None));
+ }
+ else
+ com_node(c, CHILD(ch,1));
+ }
+ com_addoparg(c, BUILD_SLICE, ns);
+}
+
+static void
+com_subscript(c, n)
+ struct compiling *c;
+ node *n;
+{
+ node *ch;
+ REQ(n, subscript);
+ ch = CHILD(n,0);
+ /* check for rubber index */
+ if (TYPE(ch) == DOT && TYPE(CHILD(n,1)) == DOT)
+ com_addoparg(c, LOAD_CONST, com_addconst(c, Py_Ellipses));
+ else {
+ /* check for slice */
+ if ((TYPE(ch) == COLON || NCH(n) > 1))
+ com_sliceobj(c, n);
+ else {
+ REQ(ch, test);
+ com_node(c, ch);
+ }
+ }
+}
+
+static void
+com_subscriptlist(c, n, assigning)
+ struct compiling *c;
+ node *n;
+ int assigning;
+{
+ int i, op;
+ REQ(n, subscriptlist);
+ /* Check to make backward compatible slice behavior for '[i:j]' */
+ if (NCH(n) == 1) {
+ node *sub = CHILD(n, 0); /* subscript */
+ /* Make it is a simple slice.
+ should have exactly one colon. */
+ if ((TYPE(CHILD(sub, 0)) == COLON
+ || (NCH(sub) > 1 && TYPE(CHILD(sub, 1)) == COLON))
+ && (TYPE(CHILD(sub,NCH(sub)-1)) != sliceop)) {
+ if (assigning == OP_APPLY)
+ op = SLICE;
+ else
+ op = ((assigning == OP_ASSIGN) ? STORE_SLICE : DELETE_SLICE);
+ com_slice(c, sub, op);
+ return;
+ }
+ }
+ /* Else normal subscriptlist. Compile each subscript. */
+ for (i = 0; i < NCH(n); i += 2)
+ com_subscript(c, CHILD(n, i));
+ /* Put multiple subscripts into a tuple */
+ if (NCH(n) > 1)
+ com_addoparg(c, BUILD_TUPLE, (NCH(n)+1) / 2);
+ if (assigning == OP_APPLY)
+ op = BINARY_SUBSCR;
+ else
+ op = ((assigning == OP_ASSIGN) ? STORE_SUBSCR : DELETE_SUBSCR);
+ com_addbyte(c, op);
+}
+
+static void
com_apply_trailer(c, n)
struct compiling *c;
node *n;
@@ -937,7 +1017,7 @@ com_apply_trailer(c, n)
com_select_member(c, CHILD(n, 1));
break;
case LSQB:
- com_apply_subscript(c, CHILD(n, 1));
+ com_subscriptlist(c, CHILD(n, 1), OP_APPLY);
break;
default:
err_setstr(SystemError,
@@ -970,6 +1050,7 @@ com_factor(c, n)
struct compiling *c;
node *n;
{
+ int i;
REQ(n, factor);
if (TYPE(CHILD(n, 0)) == PLUS) {
com_factor(c, CHILD(n, 1));
@@ -1365,33 +1446,6 @@ com_assign_attr(c, n, assigning)
}
static void
-com_assign_slice(c, n, assigning)
- struct compiling *c;
- node *n;
- int assigning;
-{
- com_slice(c, n, assigning ? STORE_SLICE : DELETE_SLICE);
-}
-
-static void
-com_assign_subscript(c, n, assigning)
- struct compiling *c;
- node *n;
- int assigning;
-{
- if (NCH(n) == 1)
- com_node(c, CHILD(n, 0));
- else {
- int i;
- int len = (NCH(n)+1)/2;
- for (i = 0; i < NCH(n); i += 2)
- com_node(c, CHILD(n, i));
- com_addoparg(c, BUILD_TUPLE, len);
- }
- com_addbyte(c, assigning ? STORE_SUBSCR : DELETE_SUBSCR);
-}
-
-static void
com_assign_trailer(c, n, assigning)
struct compiling *c;
node *n;
@@ -1406,13 +1460,8 @@ com_assign_trailer(c, n, assigning)
case DOT: /* '.' NAME */
com_assign_attr(c, CHILD(n, 1), assigning);
break;
- case LSQB: /* '[' subscript ']' */
- n = CHILD(n, 1);
- REQ(n, subscript); /* subscript: expr (',' expr)* | [expr] ':' [expr] */
- if (TYPE(CHILD(n, 0)) == COLON || (NCH(n) > 1 && TYPE(CHILD(n, 1)) == COLON))
- com_assign_slice(c, n, assigning);
- else
- com_assign_subscript(c, n, assigning);
+ case LSQB: /* '[' subscriptlist ']' */
+ com_subscriptlist(c, CHILD(n, 1), assigning);
break;
default:
err_setstr(SystemError, "unknown trailer type");
@@ -1585,7 +1634,7 @@ com_expr_stmt(c, n)
for (i = 0; i < NCH(n)-2; i+=2) {
if (i+2 < NCH(n)-2)
com_addbyte(c, DUP_TOP);
- com_assign(c, CHILD(n, i), 1/*assign*/);
+ com_assign(c, CHILD(n, i), OP_ASSIGN);
}
}
}
@@ -1896,7 +1945,7 @@ com_for_stmt(c, n)
c->c_begin = c->c_nexti;
com_addoparg(c, SET_LINENO, n->n_lineno);
com_addfwref(c, FOR_LOOP, &anchor);
- com_assign(c, CHILD(n, 1), 1/*assigning*/);
+ com_assign(c, CHILD(n, 1), OP_ASSIGN);
c->c_loops++;
com_node(c, CHILD(n, 5));
c->c_loops--;
@@ -2015,7 +2064,7 @@ com_try_except(c, n)
}
com_addbyte(c, POP_TOP);
if (NCH(ch) > 3)
- com_assign(c, CHILD(ch, 3), 1/*assigning*/);
+ com_assign(c, CHILD(ch, 3), OP_ASSIGN);
else
com_addbyte(c, POP_TOP);
com_addbyte(c, POP_TOP);
@@ -2342,7 +2391,7 @@ com_node(c, n)
com_print_stmt(c, n);
break;
case del_stmt: /* 'del' exprlist */
- com_assign(c, CHILD(n, 1), 0/*delete*/);
+ com_assign(c, CHILD(n, 1), OP_DELETE);
break;
case pass_stmt:
break;
diff --git a/Python/graminit.c b/Python/graminit.c
index f8b76ac..ce8061b 100644
--- a/Python/graminit.c
+++ b/Python/graminit.c
@@ -1031,169 +1031,204 @@ static state states_48[7] = {
{1, arcs_48_5},
{1, arcs_48_6},
};
-static arc arcs_49_0[2] = {
- {21, 1},
- {14, 2},
+static arc arcs_49_0[1] = {
+ {121, 1},
};
-static arc arcs_49_1[3] = {
- {22, 3},
- {14, 2},
+static arc arcs_49_1[2] = {
+ {22, 2},
{0, 1},
};
static arc arcs_49_2[2] = {
- {21, 4},
+ {121, 1},
+ {0, 2},
+};
+static state states_49[3] = {
+ {1, arcs_49_0},
+ {2, arcs_49_1},
+ {2, arcs_49_2},
+};
+static arc arcs_50_0[3] = {
+ {52, 1},
+ {21, 2},
+ {14, 3},
+};
+static arc arcs_50_1[1] = {
+ {52, 4},
+};
+static arc arcs_50_2[2] = {
+ {14, 3},
{0, 2},
};
-static arc arcs_49_3[2] = {
+static arc arcs_50_3[3] = {
{21, 5},
+ {122, 6},
{0, 3},
};
-static arc arcs_49_4[1] = {
- {0, 4},
+static arc arcs_50_4[1] = {
+ {52, 6},
};
-static arc arcs_49_5[2] = {
- {22, 3},
+static arc arcs_50_5[2] = {
+ {122, 6},
{0, 5},
};
-static state states_49[6] = {
- {2, arcs_49_0},
- {3, arcs_49_1},
- {2, arcs_49_2},
- {2, arcs_49_3},
- {1, arcs_49_4},
- {2, arcs_49_5},
+static arc arcs_50_6[1] = {
+ {0, 6},
+};
+static state states_50[7] = {
+ {3, arcs_50_0},
+ {1, arcs_50_1},
+ {2, arcs_50_2},
+ {3, arcs_50_3},
+ {1, arcs_50_4},
+ {2, arcs_50_5},
+ {1, arcs_50_6},
+};
+static arc arcs_51_0[1] = {
+ {14, 1},
+};
+static arc arcs_51_1[2] = {
+ {21, 2},
+ {0, 1},
};
-static arc arcs_50_0[1] = {
+static arc arcs_51_2[1] = {
+ {0, 2},
+};
+static state states_51[3] = {
+ {1, arcs_51_0},
+ {2, arcs_51_1},
+ {1, arcs_51_2},
+};
+static arc arcs_52_0[1] = {
{57, 1},
};
-static arc arcs_50_1[2] = {
+static arc arcs_52_1[2] = {
{22, 2},
{0, 1},
};
-static arc arcs_50_2[2] = {
+static arc arcs_52_2[2] = {
{57, 1},
{0, 2},
};
-static state states_50[3] = {
- {1, arcs_50_0},
- {2, arcs_50_1},
- {2, arcs_50_2},
+static state states_52[3] = {
+ {1, arcs_52_0},
+ {2, arcs_52_1},
+ {2, arcs_52_2},
};
-static arc arcs_51_0[1] = {
+static arc arcs_53_0[1] = {
{21, 1},
};
-static arc arcs_51_1[2] = {
+static arc arcs_53_1[2] = {
{22, 2},
{0, 1},
};
-static arc arcs_51_2[2] = {
+static arc arcs_53_2[2] = {
{21, 1},
{0, 2},
};
-static state states_51[3] = {
- {1, arcs_51_0},
- {2, arcs_51_1},
- {2, arcs_51_2},
+static state states_53[3] = {
+ {1, arcs_53_0},
+ {2, arcs_53_1},
+ {2, arcs_53_2},
};
-static arc arcs_52_0[1] = {
+static arc arcs_54_0[1] = {
{21, 1},
};
-static arc arcs_52_1[1] = {
+static arc arcs_54_1[1] = {
{14, 2},
};
-static arc arcs_52_2[1] = {
+static arc arcs_54_2[1] = {
{21, 3},
};
-static arc arcs_52_3[2] = {
+static arc arcs_54_3[2] = {
{22, 4},
{0, 3},
};
-static arc arcs_52_4[2] = {
+static arc arcs_54_4[2] = {
{21, 1},
{0, 4},
};
-static state states_52[5] = {
- {1, arcs_52_0},
- {1, arcs_52_1},
- {1, arcs_52_2},
- {2, arcs_52_3},
- {2, arcs_52_4},
+static state states_54[5] = {
+ {1, arcs_54_0},
+ {1, arcs_54_1},
+ {1, arcs_54_2},
+ {2, arcs_54_3},
+ {2, arcs_54_4},
};
-static arc arcs_53_0[1] = {
- {121, 1},
+static arc arcs_55_0[1] = {
+ {123, 1},
};
-static arc arcs_53_1[1] = {
+static arc arcs_55_1[1] = {
{12, 2},
};
-static arc arcs_53_2[2] = {
+static arc arcs_55_2[2] = {
{16, 3},
{14, 4},
};
-static arc arcs_53_3[1] = {
+static arc arcs_55_3[1] = {
{9, 5},
};
-static arc arcs_53_4[1] = {
+static arc arcs_55_4[1] = {
{15, 6},
};
-static arc arcs_53_5[1] = {
+static arc arcs_55_5[1] = {
{18, 7},
};
-static arc arcs_53_6[1] = {
+static arc arcs_55_6[1] = {
{0, 6},
};
-static arc arcs_53_7[1] = {
+static arc arcs_55_7[1] = {
{14, 4},
};
-static state states_53[8] = {
- {1, arcs_53_0},
- {1, arcs_53_1},
- {2, arcs_53_2},
- {1, arcs_53_3},
- {1, arcs_53_4},
- {1, arcs_53_5},
- {1, arcs_53_6},
- {1, arcs_53_7},
+static state states_55[8] = {
+ {1, arcs_55_0},
+ {1, arcs_55_1},
+ {2, arcs_55_2},
+ {1, arcs_55_3},
+ {1, arcs_55_4},
+ {1, arcs_55_5},
+ {1, arcs_55_6},
+ {1, arcs_55_7},
};
-static arc arcs_54_0[1] = {
- {122, 1},
+static arc arcs_56_0[1] = {
+ {124, 1},
};
-static arc arcs_54_1[2] = {
+static arc arcs_56_1[2] = {
{22, 2},
{0, 1},
};
-static arc arcs_54_2[2] = {
- {122, 1},
+static arc arcs_56_2[2] = {
+ {124, 1},
{0, 2},
};
-static state states_54[3] = {
- {1, arcs_54_0},
- {2, arcs_54_1},
- {2, arcs_54_2},
+static state states_56[3] = {
+ {1, arcs_56_0},
+ {2, arcs_56_1},
+ {2, arcs_56_2},
};
-static arc arcs_55_0[1] = {
+static arc arcs_57_0[1] = {
{21, 1},
};
-static arc arcs_55_1[2] = {
+static arc arcs_57_1[2] = {
{20, 2},
{0, 1},
};
-static arc arcs_55_2[1] = {
+static arc arcs_57_2[1] = {
{21, 3},
};
-static arc arcs_55_3[1] = {
+static arc arcs_57_3[1] = {
{0, 3},
};
-static state states_55[4] = {
- {1, arcs_55_0},
- {2, arcs_55_1},
- {1, arcs_55_2},
- {1, arcs_55_3},
+static state states_57[4] = {
+ {1, arcs_57_0},
+ {2, arcs_57_1},
+ {1, arcs_57_2},
+ {1, arcs_57_3},
};
-static dfa dfas[56] = {
+static dfa dfas[58] = {
{256, "single_input", 0, 3, states_0,
- "\004\030\001\000\140\341\153\001\071\000\001\000\140\104\171\002"},
+ "\004\030\001\000\140\341\153\001\071\000\001\000\140\104\171\010"},
{257, "file_input", 0, 2, states_1,
- "\204\030\001\000\140\341\153\001\071\000\001\000\140\104\171\002"},
+ "\204\030\001\000\140\341\153\001\071\000\001\000\140\104\171\010"},
{258, "eval_input", 0, 3, states_2,
"\000\020\001\000\000\000\000\000\000\000\001\000\140\104\171\000"},
{259, "funcdef", 0, 6, states_3,
@@ -1207,7 +1242,7 @@ static dfa dfas[56] = {
{263, "fplist", 0, 3, states_7,
"\000\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{264, "stmt", 0, 2, states_8,
- "\000\030\001\000\140\341\153\001\071\000\001\000\140\104\171\002"},
+ "\000\030\001\000\140\341\153\001\071\000\001\000\140\104\171\010"},
{265, "simple_stmt", 0, 4, states_9,
"\000\020\001\000\140\341\153\001\000\000\001\000\140\104\171\000"},
{266, "small_stmt", 0, 2, states_10,
@@ -1243,7 +1278,7 @@ static dfa dfas[56] = {
{281, "exec_stmt", 0, 7, states_25,
"\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000"},
{282, "compound_stmt", 0, 2, states_26,
- "\000\010\000\000\000\000\000\000\071\000\000\000\000\000\000\002"},
+ "\000\010\000\000\000\000\000\000\071\000\000\000\000\000\000\010"},
{283, "if_stmt", 0, 8, states_27,
"\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000"},
{284, "while_stmt", 0, 8, states_28,
@@ -1288,22 +1323,26 @@ static dfa dfas[56] = {
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100\000"},
{304, "trailer", 0, 7, states_48,
"\000\000\001\000\000\000\020\000\000\000\000\000\000\100\000\000"},
- {305, "subscript", 0, 6, states_49,
- "\000\120\001\000\000\000\000\000\000\000\001\000\140\104\171\000"},
- {306, "exprlist", 0, 3, states_50,
+ {305, "subscriptlist", 0, 3, states_49,
+ "\000\120\001\000\000\000\020\000\000\000\001\000\140\104\171\000"},
+ {306, "subscript", 0, 7, states_50,
+ "\000\120\001\000\000\000\020\000\000\000\001\000\140\104\171\000"},
+ {307, "sliceop", 0, 3, states_51,
+ "\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+ {308, "exprlist", 0, 3, states_52,
"\000\020\001\000\000\000\000\000\000\000\000\000\140\104\071\000"},
- {307, "testlist", 0, 3, states_51,
+ {309, "testlist", 0, 3, states_53,
"\000\020\001\000\000\000\000\000\000\000\001\000\140\104\171\000"},
- {308, "dictmaker", 0, 5, states_52,
+ {310, "dictmaker", 0, 5, states_54,
"\000\020\001\000\000\000\000\000\000\000\001\000\140\104\171\000"},
- {309, "classdef", 0, 8, states_53,
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"},
- {310, "arglist", 0, 3, states_54,
+ {311, "classdef", 0, 8, states_55,
+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010"},
+ {312, "arglist", 0, 3, states_56,
"\000\020\001\000\000\000\000\000\000\000\001\000\140\104\171\000"},
- {311, "argument", 0, 4, states_55,
+ {313, "argument", 0, 4, states_57,
"\000\020\001\000\000\000\000\000\000\000\001\000\140\104\171\000"},
};
-static label labels[123] = {
+static label labels[125] = {
{0, "EMPTY"},
{256, 0},
{4, 0},
@@ -1313,7 +1352,7 @@ static label labels[123] = {
{264, 0},
{0, 0},
{258, 0},
- {307, 0},
+ {309, 0},
{259, 0},
{1, "def"},
{1, 0},
@@ -1343,7 +1382,7 @@ static label labels[123] = {
{281, 0},
{1, "print"},
{1, "del"},
- {306, 0},
+ {308, 0},
{1, "pass"},
{272, 0},
{273, 0},
@@ -1367,7 +1406,7 @@ static label labels[123] = {
{284, 0},
{285, 0},
{286, 0},
- {309, 0},
+ {311, 0},
{1, "if"},
{1, "elif"},
{1, "else"},
@@ -1417,20 +1456,22 @@ static label labels[123] = {
{9, 0},
{10, 0},
{26, 0},
- {308, 0},
+ {310, 0},
{27, 0},
{25, 0},
{2, 0},
{3, 0},
{1, "lambda"},
- {310, 0},
+ {312, 0},
{305, 0},
+ {306, 0},
+ {307, 0},
{1, "class"},
- {311, 0},
+ {313, 0},
};
grammar gram = {
- 56,
+ 58,
dfas,
- {123, labels},
+ {125, labels},
256
};
diff --git a/Python/import.c b/Python/import.c
index d57b681..5c04f49 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -55,7 +55,7 @@ extern long getmtime(); /* In getmtime.c */
Apple MPW compiler swaps their values, botching string constants */
/* XXX Perhaps the magic number should be frozen and a version field
added to the .pyc file header? */
-#define MAGIC (1895 | ((long)'\r'<<16) | ((long)'\n'<<24))
+#define MAGIC (5892 | ((long)'\r'<<16) | ((long)'\n'<<24))
object *import_modules; /* This becomes sys.modules */
diff --git a/Python/marshal.c b/Python/marshal.c
index 509e303..4a2701a 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -37,6 +37,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define TYPE_NULL '0'
#define TYPE_NONE 'N'
+#define TYPE_ELLIPSES '.'
#define TYPE_INT 'i'
#define TYPE_FLOAT 'f'
#define TYPE_COMPLEX 'x'
@@ -129,6 +130,8 @@ w_object(v, p)
w_byte(TYPE_NULL, p);
else if (v == None)
w_byte(TYPE_NONE, p);
+ else if (v == Py_Ellipses)
+ w_byte(TYPE_ELLIPSES, p);
else if (is_intobject(v)) {
w_byte(TYPE_INT, p);
w_long(getintvalue(v), p);
@@ -322,6 +325,10 @@ r_object(p)
INCREF(None);
return None;
+ case TYPE_ELLIPSES:
+ INCREF(Py_Ellipses);
+ return Py_Ellipses;
+
case TYPE_INT:
return newintobject(r_long(p));