--- symtable_old.c 2010-06-11 20:01:04.179652965 +0000 +++ symtable.c 2010-06-11 19:56:31.998392000 +0000 @@ -38,6 +38,7 @@ goto fail; ste->ste_table = st; ste->ste_id = k; + ste->ste_tmpname = 0; ste->ste_name = name; Py_INCREF(name); @@ -65,6 +66,7 @@ ste->ste_varargs = 0; ste->ste_varkeywords = 0; ste->ste_opt_lineno = 0; + ste->ste_tmpname = 0; ste->ste_lineno = lineno; if (st->st_cur != NULL && @@ -982,7 +984,7 @@ if (flag & DEF_PARAM) { if (PyList_Append(st->st_cur->ste_varnames, mangled) < 0) goto error; - } else if (flag & DEF_GLOBAL) { + } else if (flag & DEF_GLOBAL) { /* XXX need to update DEF_GLOBAL for other flags too; perhaps only DEF_FREE_GLOBAL */ val = flag; @@ -1097,6 +1099,7 @@ } + static int symtable_visit_stmt(struct symtable *st, stmt_ty s) { @@ -1172,8 +1175,18 @@ VISIT(st, expr, s->v.Assign.value); break; case AugAssign_kind: - VISIT(st, expr, s->v.AugAssign.target); VISIT(st, expr, s->v.AugAssign.value); + if (s->v.AugAssign.target->kind == Name_kind) { + long cur = symtable_lookup(st, s->v.AugAssign.target->v.Name.id); + if (cur < 0) + return 0; + if (!cur) { + if (!symtable_add_def(st, s->v.AugAssign.target->v.Name.id, DEF_GLOBAL)) + return 0; + break; + } + } + VISIT(st, expr, s->v.AugAssign.target); break; case For_kind: VISIT(st, expr, s->v.For.target); @@ -1198,9 +1211,9 @@ case Raise_kind: if (s->v.Raise.exc) { VISIT(st, expr, s->v.Raise.exc); - if (s->v.Raise.cause) { - VISIT(st, expr, s->v.Raise.cause); - } + if (s->v.Raise.cause) { + VISIT(st, expr, s->v.Raise.cause); + } } break; case TryExcept_kind: @@ -1294,8 +1307,12 @@ /* nothing to do here */ break; case With_kind: + if (!symtable_new_tmpname(st)) + return 0; VISIT(st, expr, s->v.With.context_expr); if (s->v.With.optional_vars) { + if (!symtable_new_tmpname(st)) + return 0; VISIT(st, expr, s->v.With.optional_vars); } VISIT_SEQ(st, stmt, s->v.With.body); @@ -1319,7 +1336,8 @@ VISIT(st, expr, e->v.UnaryOp.operand); break; case Lambda_kind: { - if (!GET_IDENTIFIER(lambda)) + if (!GET_IDENTIFIER(lambda) || + !symtable_add_def(st, lambda, DEF_LOCAL)) return 0; if (e->v.Lambda.args->defaults) VISIT_SEQ(st, expr, e->v.Lambda.args->defaults); @@ -1533,7 +1551,7 @@ symtable_visit_alias(struct symtable *st, alias_ty a) { /* Compute store_name, the name actually bound by the import - operation. It is diferent than a->name when a->name is a + operation. It is different than a->name when a->name is a dotted package name (e.g. spam.eggs) */ PyObject *store_name;