comparison Python/Python-ast.c @ 41699:e16c8e5c5ca4

Merged revisions 55225-55227,55229-55269 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/p3yk ................ r55238 | guido.van.rossum | 2007-05-10 16:46:05 -0700 (Thu, 10 May 2007) | 9 lines Merged revisions 55227 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r55227 | guido.van.rossum | 2007-05-10 10:20:15 -0700 (Thu, 10 May 2007) | 2 lines Fix a bug in test_c_api() that caused a negative refcount. ........ ................ r55246 | neal.norwitz | 2007-05-11 00:01:52 -0700 (Fri, 11 May 2007) | 1 line Remove commands.getstatus() it is obsolete. ................ r55248 | neal.norwitz | 2007-05-11 00:29:05 -0700 (Fri, 11 May 2007) | 2 lines Remove bsddb185 support. ................ r55249 | neal.norwitz | 2007-05-11 00:29:50 -0700 (Fri, 11 May 2007) | 1 line Remove bsddb185 module too ................ r55250 | neal.norwitz | 2007-05-11 00:32:13 -0700 (Fri, 11 May 2007) | 1 line bsddb185: Gotta remove from the file checked in, not Setup ................ r55251 | neal.norwitz | 2007-05-11 00:53:26 -0700 (Fri, 11 May 2007) | 1 line Remove obsolete IRIX modules (as much as I could find, there is probably more) ................ r55252 | neal.norwitz | 2007-05-11 00:55:35 -0700 (Fri, 11 May 2007) | 1 line Remove SGI turd. ................ r55254 | georg.brandl | 2007-05-11 03:11:01 -0700 (Fri, 11 May 2007) | 2 lines Add a case for set comprehensions to the "cannot assign to" switch. ................ r55255 | georg.brandl | 2007-05-11 03:11:25 -0700 (Fri, 11 May 2007) | 2 lines Fix wrong imports. ................ r55261 | georg.brandl | 2007-05-11 07:37:48 -0700 (Fri, 11 May 2007) | 2 lines Remove removed tex files. ................ r55262 | georg.brandl | 2007-05-11 08:28:41 -0700 (Fri, 11 May 2007) | 2 lines Commit PEP 3132 implementation. ................ r55264 | georg.brandl | 2007-05-11 08:50:19 -0700 (Fri, 11 May 2007) | 2 lines Check in the inevitable AST version number and format Py_ssize_t with %zd. ................ r55265 | neal.norwitz | 2007-05-11 09:12:22 -0700 (Fri, 11 May 2007) | 1 line Remove mention of os.popen* and popen2.* since these will be removed. ................ r55266 | neal.norwitz | 2007-05-11 09:19:57 -0700 (Fri, 11 May 2007) | 1 line Get doc to build again (almost, the doc is fine) ................ r55267 | neal.norwitz | 2007-05-11 09:21:02 -0700 (Fri, 11 May 2007) | 1 line Really get doc to build (remove use of string module) ................ r55269 | neal.norwitz | 2007-05-11 09:29:43 -0700 (Fri, 11 May 2007) | 1 line Add some notes to cleanup later ................
author Guido van Rossum <guido@python.org>
date Fri, 11 May 2007 16:50:42 +0000
parents 3e5fdb93c95a
children 9ad84070b22d
comparison
equal deleted inserted replaced
41698:7d49038e99c9 41699:e16c8e5c5ca4
241 }; 241 };
242 static PyTypeObject *Subscript_type; 242 static PyTypeObject *Subscript_type;
243 static char *Subscript_fields[]={ 243 static char *Subscript_fields[]={
244 "value", 244 "value",
245 "slice", 245 "slice",
246 "ctx",
247 };
248 static PyTypeObject *Starred_type;
249 static char *Starred_fields[]={
250 "value",
246 "ctx", 251 "ctx",
247 }; 252 };
248 static PyTypeObject *Name_type; 253 static PyTypeObject *Name_type;
249 static char *Name_fields[]={ 254 static char *Name_fields[]={
250 "id", 255 "id",
569 if (!Ellipsis_type) return 0; 574 if (!Ellipsis_type) return 0;
570 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); 575 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3);
571 if (!Attribute_type) return 0; 576 if (!Attribute_type) return 0;
572 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3); 577 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3);
573 if (!Subscript_type) return 0; 578 if (!Subscript_type) return 0;
579 Starred_type = make_type("Starred", expr_type, Starred_fields, 2);
580 if (!Starred_type) return 0;
574 Name_type = make_type("Name", expr_type, Name_fields, 2); 581 Name_type = make_type("Name", expr_type, Name_fields, 2);
575 if (!Name_type) return 0; 582 if (!Name_type) return 0;
576 List_type = make_type("List", expr_type, List_fields, 2); 583 List_type = make_type("List", expr_type, List_fields, 2);
577 if (!List_type) return 0; 584 if (!List_type) return 0;
578 Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2); 585 Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2);
1660 p->col_offset = col_offset; 1667 p->col_offset = col_offset;
1661 return p; 1668 return p;
1662 } 1669 }
1663 1670
1664 expr_ty 1671 expr_ty
1672 Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, PyArena
1673 *arena)
1674 {
1675 expr_ty p;
1676 if (!value) {
1677 PyErr_SetString(PyExc_ValueError,
1678 "field value is required for Starred");
1679 return NULL;
1680 }
1681 if (!ctx) {
1682 PyErr_SetString(PyExc_ValueError,
1683 "field ctx is required for Starred");
1684 return NULL;
1685 }
1686 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1687 if (!p)
1688 return NULL;
1689 p->kind = Starred_kind;
1690 p->v.Starred.value = value;
1691 p->v.Starred.ctx = ctx;
1692 p->lineno = lineno;
1693 p->col_offset = col_offset;
1694 return p;
1695 }
1696
1697 expr_ty
1665 Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena 1698 Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena
1666 *arena) 1699 *arena)
1667 { 1700 {
1668 expr_ty p; 1701 expr_ty p;
1669 if (!id) { 1702 if (!id) {
2599 if (!value) goto failed; 2632 if (!value) goto failed;
2600 if (PyObject_SetAttrString(result, "slice", value) == -1) 2633 if (PyObject_SetAttrString(result, "slice", value) == -1)
2601 goto failed; 2634 goto failed;
2602 Py_DECREF(value); 2635 Py_DECREF(value);
2603 value = ast2obj_expr_context(o->v.Subscript.ctx); 2636 value = ast2obj_expr_context(o->v.Subscript.ctx);
2637 if (!value) goto failed;
2638 if (PyObject_SetAttrString(result, "ctx", value) == -1)
2639 goto failed;
2640 Py_DECREF(value);
2641 break;
2642 case Starred_kind:
2643 result = PyType_GenericNew(Starred_type, NULL, NULL);
2644 if (!result) goto failed;
2645 value = ast2obj_expr(o->v.Starred.value);
2646 if (!value) goto failed;
2647 if (PyObject_SetAttrString(result, "value", value) == -1)
2648 goto failed;
2649 Py_DECREF(value);
2650 value = ast2obj_expr_context(o->v.Starred.ctx);
2604 if (!value) goto failed; 2651 if (!value) goto failed;
2605 if (PyObject_SetAttrString(result, "ctx", value) == -1) 2652 if (PyObject_SetAttrString(result, "ctx", value) == -1)
2606 goto failed; 2653 goto failed;
2607 Py_DECREF(value); 2654 Py_DECREF(value);
2608 break; 2655 break;
3178 return; 3225 return;
3179 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < 3226 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) <
3180 0) return; 3227 0) return;
3181 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < 3228 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) <
3182 0) return; 3229 0) return;
3230 if (PyDict_SetItemString(d, "Starred", (PyObject*)Starred_type) < 0)
3231 return;
3183 if (PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return; 3232 if (PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return;
3184 if (PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return; 3233 if (PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return;
3185 if (PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return; 3234 if (PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return;
3186 if (PyDict_SetItemString(d, "expr_context", 3235 if (PyDict_SetItemString(d, "expr_context",
3187 (PyObject*)expr_context_type) < 0) return; 3236 (PyObject*)expr_context_type) < 0) return;