summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2010-01-09 23:35:54 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2010-01-09 23:35:54 (GMT)
commitee936a21308679654b2d458166ff094ed735fef7 (patch)
tree612cd109e8ede4080f58f30ece3212d8e0f996d2 /Python
parente36561352895170f28f77f0b4ec4292e35d1cc01 (diff)
downloadcpython-ee936a21308679654b2d458166ff094ed735fef7.zip
cpython-ee936a21308679654b2d458166ff094ed735fef7.tar.gz
cpython-ee936a21308679654b2d458166ff094ed735fef7.tar.bz2
Issue #2335: Backport set literals syntax from Python 3.x.
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c66
-rw-r--r--Python/ast.c65
-rw-r--r--Python/ceval.c19
-rw-r--r--Python/compile.c6
-rw-r--r--Python/graminit.c367
-rw-r--r--Python/import.c3
-rw-r--r--Python/symtable.c3
7 files changed, 345 insertions, 184 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 61e7427..4f10aa0 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -188,6 +188,10 @@ static char *Dict_fields[]={
"keys",
"values",
};
+static PyTypeObject *Set_type;
+static char *Set_fields[]={
+ "elts",
+};
static PyTypeObject *ListComp_type;
static char *ListComp_fields[]={
"elt",
@@ -718,6 +722,8 @@ static int init_types(void)
if (!IfExp_type) return 0;
Dict_type = make_type("Dict", expr_type, Dict_fields, 2);
if (!Dict_type) return 0;
+ Set_type = make_type("Set", expr_type, Set_fields, 1);
+ if (!Set_type) return 0;
ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2);
if (!ListComp_type) return 0;
GeneratorExp_type = make_type("GeneratorExp", expr_type,
@@ -1590,6 +1596,20 @@ Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena
}
expr_ty
+Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena)
+{
+ expr_ty p;
+ p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = Set_kind;
+ p->v.Set.elts = elts;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ return p;
+}
+
+expr_ty
ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
PyArena *arena)
{
@@ -2566,6 +2586,15 @@ ast2obj_expr(void* _o)
goto failed;
Py_DECREF(value);
break;
+ case Set_kind:
+ result = PyType_GenericNew(Set_type, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_list(o->v.Set.elts, ast2obj_expr);
+ if (!value) goto failed;
+ if (PyObject_SetAttrString(result, "elts", value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
case ListComp_kind:
result = PyType_GenericNew(ListComp_type, NULL, NULL);
if (!result) goto failed;
@@ -4860,6 +4889,42 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Set_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ asdl_seq* elts;
+
+ if (PyObject_HasAttrString(obj, "elts")) {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ tmp = PyObject_GetAttrString(obj, "elts");
+ if (tmp == NULL) goto failed;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
+ goto failed;
+ }
+ len = PyList_GET_SIZE(tmp);
+ elts = asdl_seq_new(len, arena);
+ if (elts == NULL) goto failed;
+ for (i = 0; i < len; i++) {
+ expr_ty value;
+ res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
+ if (res != 0) goto failed;
+ asdl_seq_SET(elts, i, value);
+ }
+ Py_XDECREF(tmp);
+ tmp = NULL;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set");
+ return 1;
+ }
+ *out = Set(elts, lineno, col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type);
if (isinstance == -1) {
return 1;
@@ -6351,6 +6416,7 @@ init_ast(void)
return;
if (PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return;
if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return;
+ if (PyDict_SetItemString(d, "Set", (PyObject*)Set_type) < 0) return;
if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0)
return;
if (PyDict_SetItemString(d, "GeneratorExp",
diff --git a/Python/ast.c b/Python/ast.c
index c8875e0..01d1f7a 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -1383,36 +1383,59 @@ ast_for_atom(struct compiling *c, const node *n)
else
return ast_for_listcomp(c, ch);
case LBRACE: {
- /* dictmaker: test ':' test (',' test ':' test)* [','] */
+ /* dictorsetmaker: test ':' test (',' test ':' test)* [','] |
+ * test (',' test)* [','])
+ */
int i, size;
asdl_seq *keys, *values;
-
+
ch = CHILD(n, 1);
- size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */
- keys = asdl_seq_new(size, c->c_arena);
- if (!keys)
- return NULL;
-
- values = asdl_seq_new(size, c->c_arena);
- if (!values)
- return NULL;
-
- for (i = 0; i < NCH(ch); i += 4) {
- expr_ty expression;
+ if (TYPE(ch) == RBRACE) {
+ /* it's an empty dict */
+ return Dict(NULL, NULL, LINENO(n), n->n_col_offset, c->c_arena);
+ } else if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) {
+ /* it's a simple set */
+ asdl_seq *elts;
+ size = (NCH(ch) + 1) / 2; /* +1 in case no trailing comma */
+ elts = asdl_seq_new(size, c->c_arena);
+ if (!elts)
+ return NULL;
+ for (i = 0; i < NCH(ch); i += 2) {
+ expr_ty expression;
+ expression = ast_for_expr(c, CHILD(ch, i));
+ if (!expression)
+ return NULL;
+ asdl_seq_SET(elts, i / 2, expression);
+ }
+ return Set(elts, LINENO(n), n->n_col_offset, c->c_arena);
+ } else {
+ /* it's a dict */
+ size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */
+ keys = asdl_seq_new(size, c->c_arena);
+ if (!keys)
+ return NULL;
- expression = ast_for_expr(c, CHILD(ch, i));
- if (!expression)
+ values = asdl_seq_new(size, c->c_arena);
+ if (!values)
return NULL;
+
+ for (i = 0; i < NCH(ch); i += 4) {
+ expr_ty expression;
+
+ expression = ast_for_expr(c, CHILD(ch, i));
+ if (!expression)
+ return NULL;
- asdl_seq_SET(keys, i / 4, expression);
+ asdl_seq_SET(keys, i / 4, expression);
- expression = ast_for_expr(c, CHILD(ch, i + 2));
- if (!expression)
- return NULL;
+ expression = ast_for_expr(c, CHILD(ch, i + 2));
+ if (!expression)
+ return NULL;
- asdl_seq_SET(values, i / 4, expression);
+ asdl_seq_SET(values, i / 4, expression);
+ }
+ return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena);
}
- return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena);
}
case BACKQUOTE: { /* repr */
expr_ty expression;
diff --git a/Python/ceval.c b/Python/ceval.c
index e5e7046..3221ab1 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2186,6 +2186,25 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
}
break;
+ case BUILD_SET:
+ x = PySet_New(NULL);
+ if (x != NULL) {
+ for (; --oparg >= 0;) {
+ w = POP();
+ if (err == 0)
+ err = PySet_Add(x, w);
+ Py_DECREF(w);
+ }
+ if (err != 0) {
+ Py_DECREF(x);
+ break;
+ }
+ PUSH(x);
+ continue;
+ }
+ break;
+
+
case BUILD_MAP:
x = _PyDict_NewPresized((Py_ssize_t)oparg);
PUSH(x);
diff --git a/Python/compile.c b/Python/compile.c
index 03875a5..c8cab1c 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -808,6 +808,7 @@ opcode_stack_effect(int opcode, int oparg)
return 1;
case BUILD_TUPLE:
case BUILD_LIST:
+ case BUILD_SET:
return 1-oparg;
case BUILD_MAP:
return 1;
@@ -2894,6 +2895,11 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
ADDOP(c, STORE_MAP);
}
break;
+ case Set_kind:
+ n = asdl_seq_LEN(e->v.Set.elts);
+ VISIT_SEQ(c, expr, e->v.Set.elts);
+ ADDOP_I(c, BUILD_SET, n);
+ break;
case ListComp_kind:
return compiler_listcomp(c, e);
case GeneratorExp_kind:
diff --git a/Python/graminit.c b/Python/graminit.c
index 2e3e9e8..8c8fa38 100644
--- a/Python/graminit.c
+++ b/Python/graminit.c
@@ -1548,258 +1548,298 @@ static state states_72[5] = {
{2, arcs_72_4},
};
static arc arcs_73_0[1] = {
- {161, 1},
+ {28, 1},
+};
+static arc arcs_73_1[3] = {
+ {23, 2},
+ {29, 3},
+ {0, 1},
+};
+static arc arcs_73_2[1] = {
+ {28, 4},
+};
+static arc arcs_73_3[2] = {
+ {28, 5},
+ {0, 3},
+};
+static arc arcs_73_4[2] = {
+ {29, 6},
+ {0, 4},
+};
+static arc arcs_73_5[2] = {
+ {29, 3},
+ {0, 5},
+};
+static arc arcs_73_6[2] = {
+ {28, 7},
+ {0, 6},
+};
+static arc arcs_73_7[1] = {
+ {23, 2},
+};
+static state states_73[8] = {
+ {1, arcs_73_0},
+ {3, arcs_73_1},
+ {1, arcs_73_2},
+ {2, arcs_73_3},
+ {2, arcs_73_4},
+ {2, arcs_73_5},
+ {2, arcs_73_6},
+ {1, arcs_73_7},
};
-static arc arcs_73_1[1] = {
+static arc arcs_74_0[1] = {
+ {162, 1},
+};
+static arc arcs_74_1[1] = {
{21, 2},
};
-static arc arcs_73_2[2] = {
+static arc arcs_74_2[2] = {
{13, 3},
{23, 4},
};
-static arc arcs_73_3[2] = {
+static arc arcs_74_3[2] = {
{9, 5},
{15, 6},
};
-static arc arcs_73_4[1] = {
+static arc arcs_74_4[1] = {
{24, 7},
};
-static arc arcs_73_5[1] = {
+static arc arcs_74_5[1] = {
{15, 6},
};
-static arc arcs_73_6[1] = {
+static arc arcs_74_6[1] = {
{23, 4},
};
-static arc arcs_73_7[1] = {
+static arc arcs_74_7[1] = {
{0, 7},
};
-static state states_73[8] = {
- {1, arcs_73_0},
- {1, arcs_73_1},
- {2, arcs_73_2},
- {2, arcs_73_3},
- {1, arcs_73_4},
- {1, arcs_73_5},
- {1, arcs_73_6},
- {1, arcs_73_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 arc arcs_74_0[3] = {
- {162, 1},
+static arc arcs_75_0[3] = {
+ {163, 1},
{30, 2},
{31, 3},
};
-static arc arcs_74_1[2] = {
+static arc arcs_75_1[2] = {
{29, 4},
{0, 1},
};
-static arc arcs_74_2[1] = {
+static arc arcs_75_2[1] = {
{28, 5},
};
-static arc arcs_74_3[1] = {
+static arc arcs_75_3[1] = {
{28, 6},
};
-static arc arcs_74_4[4] = {
- {162, 1},
+static arc arcs_75_4[4] = {
+ {163, 1},
{30, 2},
{31, 3},
{0, 4},
};
-static arc arcs_74_5[2] = {
+static arc arcs_75_5[2] = {
{29, 7},
{0, 5},
};
-static arc arcs_74_6[1] = {
+static arc arcs_75_6[1] = {
{0, 6},
};
-static arc arcs_74_7[2] = {
- {162, 5},
+static arc arcs_75_7[2] = {
+ {163, 5},
{31, 3},
};
-static state states_74[8] = {
- {3, arcs_74_0},
- {2, arcs_74_1},
- {1, arcs_74_2},
- {1, arcs_74_3},
- {4, arcs_74_4},
- {2, arcs_74_5},
- {1, arcs_74_6},
- {2, arcs_74_7},
+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},
+ {2, arcs_75_7},
};
-static arc arcs_75_0[1] = {
+static arc arcs_76_0[1] = {
{28, 1},
};
-static arc arcs_75_1[3] = {
+static arc arcs_76_1[3] = {
{157, 2},
{27, 3},
{0, 1},
};
-static arc arcs_75_2[1] = {
+static arc arcs_76_2[1] = {
{0, 2},
};
-static arc arcs_75_3[1] = {
+static arc arcs_76_3[1] = {
{28, 2},
};
-static state states_75[4] = {
- {1, arcs_75_0},
- {3, arcs_75_1},
- {1, arcs_75_2},
- {1, arcs_75_3},
+static state states_76[4] = {
+ {1, arcs_76_0},
+ {3, arcs_76_1},
+ {1, arcs_76_2},
+ {1, arcs_76_3},
};
-static arc arcs_76_0[2] = {
+static arc arcs_77_0[2] = {
{156, 1},
- {164, 1},
+ {165, 1},
};
-static arc arcs_76_1[1] = {
+static arc arcs_77_1[1] = {
{0, 1},
};
-static state states_76[2] = {
- {2, arcs_76_0},
- {1, arcs_76_1},
+static state states_77[2] = {
+ {2, arcs_77_0},
+ {1, arcs_77_1},
};
-static arc arcs_77_0[1] = {
+static arc arcs_78_0[1] = {
{96, 1},
};
-static arc arcs_77_1[1] = {
+static arc arcs_78_1[1] = {
{61, 2},
};
-static arc arcs_77_2[1] = {
+static arc arcs_78_2[1] = {
{85, 3},
};
-static arc arcs_77_3[1] = {
+static arc arcs_78_3[1] = {
{105, 4},
};
-static arc arcs_77_4[2] = {
- {163, 5},
+static arc arcs_78_4[2] = {
+ {164, 5},
{0, 4},
};
-static arc arcs_77_5[1] = {
+static arc arcs_78_5[1] = {
{0, 5},
};
-static state states_77[6] = {
- {1, arcs_77_0},
- {1, arcs_77_1},
- {1, arcs_77_2},
- {1, arcs_77_3},
- {2, arcs_77_4},
- {1, arcs_77_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 arc arcs_78_0[1] = {
+static arc arcs_79_0[1] = {
{92, 1},
};
-static arc arcs_78_1[1] = {
+static arc arcs_79_1[1] = {
{106, 2},
};
-static arc arcs_78_2[2] = {
- {163, 3},
+static arc arcs_79_2[2] = {
+ {164, 3},
{0, 2},
};
-static arc arcs_78_3[1] = {
+static arc arcs_79_3[1] = {
{0, 3},
};
-static state states_78[4] = {
- {1, arcs_78_0},
- {1, arcs_78_1},
- {2, arcs_78_2},
- {1, arcs_78_3},
+static state states_79[4] = {
+ {1, arcs_79_0},
+ {1, arcs_79_1},
+ {2, arcs_79_2},
+ {1, arcs_79_3},
};
-static arc arcs_79_0[2] = {
+static arc arcs_80_0[2] = {
{157, 1},
- {166, 1},
+ {167, 1},
};
-static arc arcs_79_1[1] = {
+static arc arcs_80_1[1] = {
{0, 1},
};
-static state states_79[2] = {
- {2, arcs_79_0},
- {1, arcs_79_1},
+static state states_80[2] = {
+ {2, arcs_80_0},
+ {1, arcs_80_1},
};
-static arc arcs_80_0[1] = {
+static arc arcs_81_0[1] = {
{96, 1},
};
-static arc arcs_80_1[1] = {
+static arc arcs_81_1[1] = {
{61, 2},
};
-static arc arcs_80_2[1] = {
+static arc arcs_81_2[1] = {
{85, 3},
};
-static arc arcs_80_3[1] = {
+static arc arcs_81_3[1] = {
{107, 4},
};
-static arc arcs_80_4[2] = {
- {165, 5},
+static arc arcs_81_4[2] = {
+ {166, 5},
{0, 4},
};
-static arc arcs_80_5[1] = {
+static arc arcs_81_5[1] = {
{0, 5},
};
-static state states_80[6] = {
- {1, arcs_80_0},
- {1, arcs_80_1},
- {1, arcs_80_2},
- {1, arcs_80_3},
- {2, arcs_80_4},
- {1, arcs_80_5},
+static state states_81[6] = {
+ {1, arcs_81_0},
+ {1, arcs_81_1},
+ {1, arcs_81_2},
+ {1, arcs_81_3},
+ {2, arcs_81_4},
+ {1, arcs_81_5},
};
-static arc arcs_81_0[1] = {
+static arc arcs_82_0[1] = {
{92, 1},
};
-static arc arcs_81_1[1] = {
+static arc arcs_82_1[1] = {
{106, 2},
};
-static arc arcs_81_2[2] = {
- {165, 3},
+static arc arcs_82_2[2] = {
+ {166, 3},
{0, 2},
};
-static arc arcs_81_3[1] = {
+static arc arcs_82_3[1] = {
{0, 3},
};
-static state states_81[4] = {
- {1, arcs_81_0},
- {1, arcs_81_1},
- {2, arcs_81_2},
- {1, arcs_81_3},
+static state states_82[4] = {
+ {1, arcs_82_0},
+ {1, arcs_82_1},
+ {2, arcs_82_2},
+ {1, arcs_82_3},
};
-static arc arcs_82_0[1] = {
+static arc arcs_83_0[1] = {
{28, 1},
};
-static arc arcs_82_1[2] = {
+static arc arcs_83_1[2] = {
{29, 0},
{0, 1},
};
-static state states_82[2] = {
- {1, arcs_82_0},
- {2, arcs_82_1},
+static state states_83[2] = {
+ {1, arcs_83_0},
+ {2, arcs_83_1},
};
-static arc arcs_83_0[1] = {
+static arc arcs_84_0[1] = {
{21, 1},
};
-static arc arcs_83_1[1] = {
+static arc arcs_84_1[1] = {
{0, 1},
};
-static state states_83[2] = {
- {1, arcs_83_0},
- {1, arcs_83_1},
+static state states_84[2] = {
+ {1, arcs_84_0},
+ {1, arcs_84_1},
};
-static arc arcs_84_0[1] = {
- {168, 1},
+static arc arcs_85_0[1] = {
+ {169, 1},
};
-static arc arcs_84_1[2] = {
+static arc arcs_85_1[2] = {
{9, 2},
{0, 1},
};
-static arc arcs_84_2[1] = {
+static arc arcs_85_2[1] = {
{0, 2},
};
-static state states_84[3] = {
- {1, arcs_84_0},
- {2, arcs_84_1},
- {1, arcs_84_2},
+static state states_85[3] = {
+ {1, arcs_85_0},
+ {2, arcs_85_1},
+ {1, arcs_85_2},
};
-static dfa dfas[85] = {
+static dfa dfas[86] = {
{256, "single_input", 0, 3, states_0,
- "\004\050\060\000\000\000\000\124\360\024\114\220\023\040\010\000\200\041\044\015\002\001"},
+ "\004\050\060\000\000\000\000\124\360\024\114\220\023\040\010\000\200\041\044\015\004\002"},
{257, "file_input", 0, 2, states_1,
- "\204\050\060\000\000\000\000\124\360\024\114\220\023\040\010\000\200\041\044\015\002\001"},
+ "\204\050\060\000\000\000\000\124\360\024\114\220\023\040\010\000\200\041\044\015\004\002"},
{258, "eval_input", 0, 3, states_2,
"\000\040\040\000\000\000\000\000\000\000\000\000\000\040\010\000\200\041\044\015\000\000"},
{259, "decorator", 0, 7, states_3,
@@ -1819,11 +1859,11 @@ static dfa dfas[85] = {
{266, "fplist", 0, 3, states_10,
"\000\040\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{267, "stmt", 0, 2, states_11,
- "\000\050\060\000\000\000\000\124\360\024\114\220\023\040\010\000\200\041\044\015\002\001"},
+ "\000\050\060\000\000\000\000\124\360\024\114\220\023\040\010\000\200\041\044\015\004\002"},
{268, "simple_stmt", 0, 4, states_12,
- "\000\040\040\000\000\000\000\124\360\024\114\000\000\040\010\000\200\041\044\015\000\001"},
+ "\000\040\040\000\000\000\000\124\360\024\114\000\000\040\010\000\200\041\044\015\000\002"},
{269, "small_stmt", 0, 2, states_13,
- "\000\040\040\000\000\000\000\124\360\024\114\000\000\040\010\000\200\041\044\015\000\001"},
+ "\000\040\040\000\000\000\000\124\360\024\114\000\000\040\010\000\200\041\044\015\000\002"},
{270, "expr_stmt", 0, 6, states_14,
"\000\040\040\000\000\000\000\000\000\000\000\000\000\040\010\000\200\041\044\015\000\000"},
{271, "augassign", 0, 2, states_15,
@@ -1835,7 +1875,7 @@ static dfa dfas[85] = {
{274, "pass_stmt", 0, 2, states_18,
"\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{275, "flow_stmt", 0, 2, states_19,
- "\000\000\000\000\000\000\000\000\360\000\000\000\000\000\000\000\000\000\000\000\000\001"},
+ "\000\000\000\000\000\000\000\000\360\000\000\000\000\000\000\000\000\000\000\000\000\002"},
{276, "break_stmt", 0, 2, states_20,
"\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{277, "continue_stmt", 0, 2, states_21,
@@ -1843,7 +1883,7 @@ static dfa dfas[85] = {
{278, "return_stmt", 0, 3, states_22,
"\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{279, "yield_stmt", 0, 2, states_23,
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"},
+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"},
{280, "raise_stmt", 0, 7, states_24,
"\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{281, "import_stmt", 0, 2, states_25,
@@ -1869,7 +1909,7 @@ static dfa dfas[85] = {
{291, "assert_stmt", 0, 5, states_35,
"\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"},
{292, "compound_stmt", 0, 2, states_36,
- "\000\010\020\000\000\000\000\000\000\000\000\220\023\000\000\000\000\000\000\000\002\000"},
+ "\000\010\020\000\000\000\000\000\000\000\000\220\023\000\000\000\000\000\000\000\004\000"},
{293, "if_stmt", 0, 8, states_37,
"\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"},
{294, "while_stmt", 0, 8, states_38,
@@ -1885,7 +1925,7 @@ static dfa dfas[85] = {
{299, "except_clause", 0, 5, states_43,
"\000\000\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000"},
{300, "suite", 0, 5, states_44,
- "\004\040\040\000\000\000\000\124\360\024\114\000\000\040\010\000\200\041\044\015\000\001"},
+ "\004\040\040\000\000\000\000\124\360\024\114\000\000\040\010\000\200\041\044\015\000\002"},
{301, "testlist_safe", 0, 5, states_45,
"\000\040\040\000\000\000\000\000\000\000\000\000\000\040\010\000\200\041\044\015\000\000"},
{302, "old_test", 0, 2, states_46,
@@ -1942,32 +1982,34 @@ static dfa dfas[85] = {
"\000\040\040\000\000\000\000\000\000\000\000\000\000\040\010\000\200\041\044\015\000\000"},
{328, "dictmaker", 0, 5, states_72,
"\000\040\040\000\000\000\000\000\000\000\000\000\000\040\010\000\200\041\044\015\000\000"},
- {329, "classdef", 0, 8, states_73,
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000"},
- {330, "arglist", 0, 8, states_74,
+ {329, "dictorsetmaker", 0, 8, states_73,
+ "\000\040\040\000\000\000\000\000\000\000\000\000\000\040\010\000\200\041\044\015\000\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\000\004\000"},
+ {331, "arglist", 0, 8, states_75,
"\000\040\040\300\000\000\000\000\000\000\000\000\000\040\010\000\200\041\044\015\000\000"},
- {331, "argument", 0, 4, states_75,
+ {332, "argument", 0, 4, states_76,
"\000\040\040\000\000\000\000\000\000\000\000\000\000\040\010\000\200\041\044\015\000\000"},
- {332, "list_iter", 0, 2, states_76,
+ {333, "list_iter", 0, 2, states_77,
"\000\000\000\000\000\000\000\000\000\000\000\020\001\000\000\000\000\000\000\000\000\000"},
- {333, "list_for", 0, 6, states_77,
+ {334, "list_for", 0, 6, states_78,
"\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000"},
- {334, "list_if", 0, 4, states_78,
+ {335, "list_if", 0, 4, states_79,
"\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"},
- {335, "gen_iter", 0, 2, states_79,
+ {336, "gen_iter", 0, 2, states_80,
"\000\000\000\000\000\000\000\000\000\000\000\020\001\000\000\000\000\000\000\000\000\000"},
- {336, "gen_for", 0, 6, states_80,
+ {337, "gen_for", 0, 6, states_81,
"\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000"},
- {337, "gen_if", 0, 4, states_81,
+ {338, "gen_if", 0, 4, states_82,
"\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"},
- {338, "testlist1", 0, 2, states_82,
+ {339, "testlist1", 0, 2, states_83,
"\000\040\040\000\000\000\000\000\000\000\000\000\000\040\010\000\200\041\044\015\000\000"},
- {339, "encoding_decl", 0, 2, states_83,
+ {340, "encoding_decl", 0, 2, states_84,
"\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
- {340, "yield_expr", 0, 3, states_84,
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"},
+ {341, "yield_expr", 0, 3, states_85,
+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"},
};
-static label labels[169] = {
+static label labels[170] = {
{0, "EMPTY"},
{256, 0},
{4, 0},
@@ -1982,11 +2024,11 @@ static label labels[169] = {
{50, 0},
{288, 0},
{7, 0},
- {330, 0},
+ {331, 0},
{8, 0},
{260, 0},
{261, 0},
- {329, 0},
+ {330, 0},
{262, 0},
{1, "def"},
{1, 0},
@@ -2013,7 +2055,7 @@ static label labels[169] = {
{290, 0},
{291, 0},
{271, 0},
- {340, 0},
+ {341, 0},
{37, 0},
{38, 0},
{39, 0},
@@ -2118,29 +2160,30 @@ static label labels[169] = {
{319, 0},
{10, 0},
{26, 0},
- {328, 0},
+ {329, 0},
{27, 0},
{25, 0},
- {338, 0},
+ {339, 0},
{2, 0},
{3, 0},
- {333, 0},
- {336, 0},
+ {334, 0},
+ {337, 0},
{323, 0},
{324, 0},
{325, 0},
+ {328, 0},
{1, "class"},
- {331, 0},
{332, 0},
- {334, 0},
+ {333, 0},
{335, 0},
- {337, 0},
- {339, 0},
+ {336, 0},
+ {338, 0},
+ {340, 0},
{1, "yield"},
};
grammar _PyParser_Grammar = {
- 85,
+ 86,
dfas,
- {169, labels},
+ {170, labels},
256
};
diff --git a/Python/import.c b/Python/import.c
index 3ca452a..3df70a8 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -75,9 +75,10 @@ typedef unsigned short mode_t;
Python 2.7a0: 62181 (optimize conditional branches:
introduce POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE)
Python 2.7a0 62191 (introduce SETUP_WITH)
+ Python 2.7a0 62201 (introduce BUILD_SET)
.
*/
-#define MAGIC (62191 | ((long)'\r'<<16) | ((long)'\n'<<24))
+#define MAGIC (62201 | ((long)'\r'<<16) | ((long)'\n'<<24))
/* Magic word as global; note that _PyImport_Init() can change the
value of this global to accommodate for alterations of how the
diff --git a/Python/symtable.c b/Python/symtable.c
index d782a19..5e735cc 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -1211,6 +1211,9 @@ symtable_visit_expr(struct symtable *st, expr_ty e)
VISIT_SEQ(st, expr, e->v.Dict.keys);
VISIT_SEQ(st, expr, e->v.Dict.values);
break;
+ case Set_kind:
+ VISIT_SEQ(st, expr, e->v.Set.elts);
+ break;
case ListComp_kind:
VISIT(st, expr, e->v.ListComp.elt);
VISIT_SEQ(st, comprehension, e->v.ListComp.generators);