Mercurial > cpython-lru_cache-weakref
diff Python/compile.c @ 35779:19d796bd740f legacy-trunk
Fix private name mangling. The symtable also must do mangles so that
the scope of names can be correctly determined.
| author | Neil Schemenauer <nascheme@enme.ucalgary.ca> |
|---|---|
| date | Sun, 23 Oct 2005 18:37:42 +0000 |
| parents | 95d0a857ae51 |
| children | 31d36dd5959c |
line wrap: on
line diff
--- a/Python/compile.c Sun Oct 23 17:21:54 2005 +0000 +++ b/Python/compile.c Sun Oct 23 18:37:42 2005 +0000 @@ -2701,10 +2701,11 @@ static int compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx) { - int op, scope; + int op, scope, r, arg; enum { OP_FAST, OP_GLOBAL, OP_DEREF, OP_NAME } optype; PyObject *dict = c->u->u_names; + PyObject *mangled; /* XXX AugStore isn't used anywhere! */ /* First check for assignment to __debug__. Param? */ @@ -2713,9 +2714,13 @@ return compiler_error(c, "can not assign to __debug__"); } + mangled = _Py_Mangle(c->u->u_private, name); + if (!mangled) + return 0; + op = 0; optype = OP_NAME; - scope = PyST_GetScope(c->u->u_ste, name); + scope = PyST_GetScope(c->u->u_ste, mangled); switch (scope) { case FREE: dict = c->u->u_freevars; @@ -2755,6 +2760,7 @@ "can not delete variable '%s' referenced " "in nested scope", PyString_AS_STRING(name)); + Py_DECREF(mangled); return 0; break; case Param: @@ -2772,7 +2778,8 @@ case Param: assert(0); /* impossible */ } - ADDOP_O(c, op, name, varnames); + ADDOP_O(c, op, mangled, varnames); + Py_DECREF(mangled); return 1; case OP_GLOBAL: switch (ctx) { @@ -2801,7 +2808,12 @@ } assert(op); - return compiler_addop_name(c, op, dict, name); + arg = compiler_add_o(c, dict, mangled); + if (arg < 0) + return 0; + r = compiler_addop_i(c, op, arg); + Py_DECREF(mangled); + return r; } static int
