Index: Python/symtable.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/symtable.c,v retrieving revision 2.10.8.30 diff -u -p -r2.10.8.30 symtable.c --- Python/symtable.c 16 Jan 2005 17:09:12 -0000 2.10.8.30 +++ Python/symtable.c 23 Mar 2005 00:45:31 -0000 @@ -509,7 +510,7 @@ analyze_block(PySTEntryObject *ste, PyOb PyObject *global) { PyObject *name, *v, *local = NULL, *scope = NULL, *newbound = NULL; - PyObject *newglobal = NULL; + PyObject *newglobal = NULL, *newfree = NULL; int i, flags, pos = 0, success = 0; local = PyDict_New(); @@ -521,6 +522,9 @@ analyze_block(PySTEntryObject *ste, PyOb newglobal = PyDict_New(); if (!newglobal) goto error; + newfree = PyDict_New(); + if (!newfree) + goto error; newbound = PyDict_New(); if (!newbound) goto error; @@ -562,22 +566,26 @@ analyze_block(PySTEntryObject *ste, PyOb for (i = 0; i < PyList_GET_SIZE(ste->ste_children); ++i) { PyObject *c = PyList_GET_ITEM(ste->ste_children, i); assert(c && PySTEntry_Check(c)); - if (!analyze_block((PySTEntryObject *)c, newbound, free, + if (!analyze_block((PySTEntryObject *)c, newbound, newfree, newglobal)) goto error; } - if (ste->ste_type == FunctionBlock && !analyze_cells(scope, free)) + if (ste->ste_type == FunctionBlock && !analyze_cells(scope, newfree)) goto error; - if (!update_symbols(ste->ste_symbols, scope, bound, free, + if (!update_symbols(ste->ste_symbols, scope, bound, newfree, ste->ste_type == ClassBlock)) goto error; + + if (PyDict_Update(free, newfree, local) < 0) + goto error; success = 1; error: Py_XDECREF(local); Py_XDECREF(scope); Py_XDECREF(newbound); Py_XDECREF(newglobal); + Py_XDECREF(newfree); if (!success) assert(PyErr_Occurred()); return success; /* XXX this is correct/complete */ @@ -953,8 +962,11 @@ symtable_visit_expr(struct symtable *st, if (!symtable_enter_block(st, tmp, FunctionBlock, (void *)e, 0)) return 0; + if (!symtable_implicit_arg(st, 0)) + return 0; VISIT(st, expr, e->v.GeneratorComp.elt); VISIT_SEQ(st, comprehension, e->v.GeneratorComp.generators); + st->st_cur->ste_generator = 1; symtable_exit_block(st, (void *)e); break; }