bpo-39988: Remove ast.AugLoad and ast.AugStore node classes. (GH-19038)
This commit is contained in:
parent
dab8423d22
commit
6b97598fb6
|
@ -678,9 +678,10 @@ Removed
|
||||||
defining ``COUNT_ALLOCS`` macro.
|
defining ``COUNT_ALLOCS`` macro.
|
||||||
(Contributed by Victor Stinner in :issue:`39489`.)
|
(Contributed by Victor Stinner in :issue:`39489`.)
|
||||||
|
|
||||||
* The ``ast.Suite`` and ``ast.Param`` node classes has been removed due to no
|
* The ``ast.Suite``, ``ast.Param``, ``ast.AugLoad`` and ``ast.AugStore``
|
||||||
longer being needed.
|
node classes have been removed due to no longer being needed.
|
||||||
(Contributed by Batuhan Taskaya in :issue:`39639` and :issue:`39969`.)
|
(Contributed by Batuhan Taskaya in :issue:`39639` and :issue:`39969`
|
||||||
|
and Serhiy Storchaka in :issue:`39988`.)
|
||||||
|
|
||||||
|
|
||||||
Porting to Python 3.9
|
Porting to Python 3.9
|
||||||
|
|
|
@ -17,8 +17,7 @@ typedef struct _stmt *stmt_ty;
|
||||||
|
|
||||||
typedef struct _expr *expr_ty;
|
typedef struct _expr *expr_ty;
|
||||||
|
|
||||||
typedef enum _expr_context { Load=1, Store=2, Del=3, AugLoad=4, AugStore=5 }
|
typedef enum _expr_context { Load=1, Store=2, Del=3 } expr_context_ty;
|
||||||
expr_context_ty;
|
|
||||||
|
|
||||||
typedef enum _boolop { And=1, Or=2 } boolop_ty;
|
typedef enum _boolop { And=1, Or=2 } boolop_ty;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Removed ``ast.AugLoad`` and ``ast.AugStore`` node classes because they are
|
||||||
|
no longer used.
|
|
@ -90,7 +90,7 @@ module Python
|
||||||
-- col_offset is the byte offset in the utf8 string the parser uses
|
-- col_offset is the byte offset in the utf8 string the parser uses
|
||||||
attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)
|
attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)
|
||||||
|
|
||||||
expr_context = Load | Store | Del | AugLoad | AugStore
|
expr_context = Load | Store | Del
|
||||||
|
|
||||||
boolop = And | Or
|
boolop = And | Or
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,6 @@ typedef struct {
|
||||||
PyObject *AsyncWith_type;
|
PyObject *AsyncWith_type;
|
||||||
PyObject *Attribute_type;
|
PyObject *Attribute_type;
|
||||||
PyObject *AugAssign_type;
|
PyObject *AugAssign_type;
|
||||||
PyObject *AugLoad_singleton;
|
|
||||||
PyObject *AugLoad_type;
|
|
||||||
PyObject *AugStore_singleton;
|
|
||||||
PyObject *AugStore_type;
|
|
||||||
PyObject *Await_type;
|
PyObject *Await_type;
|
||||||
PyObject *BinOp_type;
|
PyObject *BinOp_type;
|
||||||
PyObject *BitAnd_singleton;
|
PyObject *BitAnd_singleton;
|
||||||
|
@ -245,10 +241,6 @@ static int astmodule_clear(PyObject *module)
|
||||||
Py_CLEAR(astmodulestate(module)->AsyncWith_type);
|
Py_CLEAR(astmodulestate(module)->AsyncWith_type);
|
||||||
Py_CLEAR(astmodulestate(module)->Attribute_type);
|
Py_CLEAR(astmodulestate(module)->Attribute_type);
|
||||||
Py_CLEAR(astmodulestate(module)->AugAssign_type);
|
Py_CLEAR(astmodulestate(module)->AugAssign_type);
|
||||||
Py_CLEAR(astmodulestate(module)->AugLoad_singleton);
|
|
||||||
Py_CLEAR(astmodulestate(module)->AugLoad_type);
|
|
||||||
Py_CLEAR(astmodulestate(module)->AugStore_singleton);
|
|
||||||
Py_CLEAR(astmodulestate(module)->AugStore_type);
|
|
||||||
Py_CLEAR(astmodulestate(module)->Await_type);
|
Py_CLEAR(astmodulestate(module)->Await_type);
|
||||||
Py_CLEAR(astmodulestate(module)->BinOp_type);
|
Py_CLEAR(astmodulestate(module)->BinOp_type);
|
||||||
Py_CLEAR(astmodulestate(module)->BitAnd_singleton);
|
Py_CLEAR(astmodulestate(module)->BitAnd_singleton);
|
||||||
|
@ -468,10 +460,6 @@ static int astmodule_traverse(PyObject *module, visitproc visit, void* arg)
|
||||||
Py_VISIT(astmodulestate(module)->AsyncWith_type);
|
Py_VISIT(astmodulestate(module)->AsyncWith_type);
|
||||||
Py_VISIT(astmodulestate(module)->Attribute_type);
|
Py_VISIT(astmodulestate(module)->Attribute_type);
|
||||||
Py_VISIT(astmodulestate(module)->AugAssign_type);
|
Py_VISIT(astmodulestate(module)->AugAssign_type);
|
||||||
Py_VISIT(astmodulestate(module)->AugLoad_singleton);
|
|
||||||
Py_VISIT(astmodulestate(module)->AugLoad_type);
|
|
||||||
Py_VISIT(astmodulestate(module)->AugStore_singleton);
|
|
||||||
Py_VISIT(astmodulestate(module)->AugStore_type);
|
|
||||||
Py_VISIT(astmodulestate(module)->Await_type);
|
Py_VISIT(astmodulestate(module)->Await_type);
|
||||||
Py_VISIT(astmodulestate(module)->BinOp_type);
|
Py_VISIT(astmodulestate(module)->BinOp_type);
|
||||||
Py_VISIT(astmodulestate(module)->BitAnd_singleton);
|
Py_VISIT(astmodulestate(module)->BitAnd_singleton);
|
||||||
|
@ -1728,7 +1716,7 @@ static int init_types(void)
|
||||||
return 0;
|
return 0;
|
||||||
state->expr_context_type = make_type("expr_context", state->AST_type, NULL,
|
state->expr_context_type = make_type("expr_context", state->AST_type, NULL,
|
||||||
0,
|
0,
|
||||||
"expr_context = Load | Store | Del | AugLoad | AugStore");
|
"expr_context = Load | Store | Del");
|
||||||
if (!state->expr_context_type) return 0;
|
if (!state->expr_context_type) return 0;
|
||||||
if (!add_attributes(state->expr_context_type, NULL, 0)) return 0;
|
if (!add_attributes(state->expr_context_type, NULL, 0)) return 0;
|
||||||
state->Load_type = make_type("Load", state->expr_context_type, NULL, 0,
|
state->Load_type = make_type("Load", state->expr_context_type, NULL, 0,
|
||||||
|
@ -1749,22 +1737,6 @@ static int init_types(void)
|
||||||
state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
|
state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
if (!state->Del_singleton) return 0;
|
if (!state->Del_singleton) return 0;
|
||||||
state->AugLoad_type = make_type("AugLoad", state->expr_context_type, NULL,
|
|
||||||
0,
|
|
||||||
"AugLoad");
|
|
||||||
if (!state->AugLoad_type) return 0;
|
|
||||||
state->AugLoad_singleton = PyType_GenericNew((PyTypeObject
|
|
||||||
*)state->AugLoad_type, NULL,
|
|
||||||
NULL);
|
|
||||||
if (!state->AugLoad_singleton) return 0;
|
|
||||||
state->AugStore_type = make_type("AugStore", state->expr_context_type,
|
|
||||||
NULL, 0,
|
|
||||||
"AugStore");
|
|
||||||
if (!state->AugStore_type) return 0;
|
|
||||||
state->AugStore_singleton = PyType_GenericNew((PyTypeObject
|
|
||||||
*)state->AugStore_type, NULL,
|
|
||||||
NULL);
|
|
||||||
if (!state->AugStore_singleton) return 0;
|
|
||||||
state->boolop_type = make_type("boolop", state->AST_type, NULL, 0,
|
state->boolop_type = make_type("boolop", state->AST_type, NULL, 0,
|
||||||
"boolop = And | Or");
|
"boolop = And | Or");
|
||||||
if (!state->boolop_type) return 0;
|
if (!state->boolop_type) return 0;
|
||||||
|
@ -4614,12 +4586,6 @@ PyObject* ast2obj_expr_context(expr_context_ty o)
|
||||||
case Del:
|
case Del:
|
||||||
Py_INCREF(astmodulestate_global->Del_singleton);
|
Py_INCREF(astmodulestate_global->Del_singleton);
|
||||||
return astmodulestate_global->Del_singleton;
|
return astmodulestate_global->Del_singleton;
|
||||||
case AugLoad:
|
|
||||||
Py_INCREF(astmodulestate_global->AugLoad_singleton);
|
|
||||||
return astmodulestate_global->AugLoad_singleton;
|
|
||||||
case AugStore:
|
|
||||||
Py_INCREF(astmodulestate_global->AugStore_singleton);
|
|
||||||
return astmodulestate_global->AugStore_singleton;
|
|
||||||
default:
|
default:
|
||||||
/* should never happen, but just in case ... */
|
/* should never happen, but just in case ... */
|
||||||
PyErr_Format(PyExc_SystemError, "unknown expr_context found");
|
PyErr_Format(PyExc_SystemError, "unknown expr_context found");
|
||||||
|
@ -8809,22 +8775,6 @@ obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena)
|
||||||
*out = Del;
|
*out = Del;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
isinstance = PyObject_IsInstance(obj, astmodulestate_global->AugLoad_type);
|
|
||||||
if (isinstance == -1) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (isinstance) {
|
|
||||||
*out = AugLoad;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
isinstance = PyObject_IsInstance(obj, astmodulestate_global->AugStore_type);
|
|
||||||
if (isinstance == -1) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (isinstance) {
|
|
||||||
*out = AugStore;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
|
PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -10163,16 +10113,6 @@ PyInit__ast(void)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
Py_INCREF(astmodulestate(m)->Del_type);
|
Py_INCREF(astmodulestate(m)->Del_type);
|
||||||
if (PyModule_AddObject(m, "AugLoad", astmodulestate_global->AugLoad_type) <
|
|
||||||
0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
Py_INCREF(astmodulestate(m)->AugLoad_type);
|
|
||||||
if (PyModule_AddObject(m, "AugStore", astmodulestate_global->AugStore_type)
|
|
||||||
< 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
Py_INCREF(astmodulestate(m)->AugStore_type);
|
|
||||||
if (PyModule_AddObject(m, "boolop", astmodulestate_global->boolop_type) <
|
if (PyModule_AddObject(m, "boolop", astmodulestate_global->boolop_type) <
|
||||||
0) {
|
0) {
|
||||||
goto error;
|
goto error;
|
||||||
|
|
13
Python/ast.c
13
Python/ast.c
|
@ -71,10 +71,6 @@ expr_context_name(expr_context_ty ctx)
|
||||||
return "Store";
|
return "Store";
|
||||||
case Del:
|
case Del:
|
||||||
return "Del";
|
return "Del";
|
||||||
case AugLoad:
|
|
||||||
return "AugLoad";
|
|
||||||
case AugStore:
|
|
||||||
return "AugStore";
|
|
||||||
default:
|
default:
|
||||||
Py_UNREACHABLE();
|
Py_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
@ -1099,14 +1095,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
|
||||||
{
|
{
|
||||||
asdl_seq *s = NULL;
|
asdl_seq *s = NULL;
|
||||||
|
|
||||||
/* The ast defines augmented store and load contexts, but the
|
/* Expressions in an augmented assignment have a Store context. */
|
||||||
implementation here doesn't actually use them. The code may be
|
|
||||||
a little more complex than necessary as a result. It also means
|
|
||||||
that expressions in an augmented assignment have a Store context.
|
|
||||||
Consider restructuring so that augmented assignment uses
|
|
||||||
set_context(), too.
|
|
||||||
*/
|
|
||||||
assert(ctx != AugStore && ctx != AugLoad);
|
|
||||||
|
|
||||||
switch (e->kind) {
|
switch (e->kind) {
|
||||||
case Attribute_kind:
|
case Attribute_kind:
|
||||||
|
|
145
Python/compile.c
145
Python/compile.c
|
@ -3506,7 +3506,6 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
|
||||||
|
|
||||||
PyObject *dict = c->u->u_names;
|
PyObject *dict = c->u->u_names;
|
||||||
PyObject *mangled;
|
PyObject *mangled;
|
||||||
/* XXX AugStore isn't used anywhere! */
|
|
||||||
|
|
||||||
assert(!_PyUnicode_EqualToASCIIString(name, "None") &&
|
assert(!_PyUnicode_EqualToASCIIString(name, "None") &&
|
||||||
!_PyUnicode_EqualToASCIIString(name, "True") &&
|
!_PyUnicode_EqualToASCIIString(name, "True") &&
|
||||||
|
@ -3553,70 +3552,30 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
|
||||||
case Load:
|
case Load:
|
||||||
op = (c->u->u_ste->ste_type == ClassBlock) ? LOAD_CLASSDEREF : LOAD_DEREF;
|
op = (c->u->u_ste->ste_type == ClassBlock) ? LOAD_CLASSDEREF : LOAD_DEREF;
|
||||||
break;
|
break;
|
||||||
case Store:
|
case Store: op = STORE_DEREF; break;
|
||||||
op = STORE_DEREF;
|
|
||||||
break;
|
|
||||||
case AugLoad:
|
|
||||||
case AugStore:
|
|
||||||
break;
|
|
||||||
case Del: op = DELETE_DEREF; break;
|
case Del: op = DELETE_DEREF; break;
|
||||||
default:
|
|
||||||
PyErr_Format(PyExc_SystemError,
|
|
||||||
"expr_context kind %d should not be possible",
|
|
||||||
ctx);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OP_FAST:
|
case OP_FAST:
|
||||||
switch (ctx) {
|
switch (ctx) {
|
||||||
case Load: op = LOAD_FAST; break;
|
case Load: op = LOAD_FAST; break;
|
||||||
case Store:
|
case Store: op = STORE_FAST; break;
|
||||||
op = STORE_FAST;
|
|
||||||
break;
|
|
||||||
case Del: op = DELETE_FAST; break;
|
case Del: op = DELETE_FAST; break;
|
||||||
case AugLoad:
|
|
||||||
case AugStore:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
PyErr_Format(PyExc_SystemError,
|
|
||||||
"expr_context kind %d should not be possible",
|
|
||||||
ctx);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
ADDOP_N(c, op, mangled, varnames);
|
ADDOP_N(c, op, mangled, varnames);
|
||||||
return 1;
|
return 1;
|
||||||
case OP_GLOBAL:
|
case OP_GLOBAL:
|
||||||
switch (ctx) {
|
switch (ctx) {
|
||||||
case Load: op = LOAD_GLOBAL; break;
|
case Load: op = LOAD_GLOBAL; break;
|
||||||
case Store:
|
case Store: op = STORE_GLOBAL; break;
|
||||||
op = STORE_GLOBAL;
|
|
||||||
break;
|
|
||||||
case Del: op = DELETE_GLOBAL; break;
|
case Del: op = DELETE_GLOBAL; break;
|
||||||
case AugLoad:
|
|
||||||
case AugStore:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
PyErr_Format(PyExc_SystemError,
|
|
||||||
"expr_context kind %d should not be possible",
|
|
||||||
ctx);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OP_NAME:
|
case OP_NAME:
|
||||||
switch (ctx) {
|
switch (ctx) {
|
||||||
case Load: op = LOAD_NAME; break;
|
case Load: op = LOAD_NAME; break;
|
||||||
case Store:
|
case Store: op = STORE_NAME; break;
|
||||||
op = STORE_NAME;
|
|
||||||
break;
|
|
||||||
case Del: op = DELETE_NAME; break;
|
case Del: op = DELETE_NAME; break;
|
||||||
case AugLoad:
|
|
||||||
case AugStore:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
PyErr_Format(PyExc_SystemError,
|
|
||||||
"expr_context kind %d should not be possible",
|
|
||||||
ctx);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5021,29 +4980,17 @@ compiler_visit_expr1(struct compiler *c, expr_ty e)
|
||||||
return compiler_formatted_value(c, e);
|
return compiler_formatted_value(c, e);
|
||||||
/* The following exprs can be assignment targets. */
|
/* The following exprs can be assignment targets. */
|
||||||
case Attribute_kind:
|
case Attribute_kind:
|
||||||
if (e->v.Attribute.ctx != AugStore)
|
VISIT(c, expr, e->v.Attribute.value);
|
||||||
VISIT(c, expr, e->v.Attribute.value);
|
|
||||||
switch (e->v.Attribute.ctx) {
|
switch (e->v.Attribute.ctx) {
|
||||||
case AugLoad:
|
|
||||||
ADDOP(c, DUP_TOP);
|
|
||||||
/* Fall through */
|
|
||||||
case Load:
|
case Load:
|
||||||
ADDOP_NAME(c, LOAD_ATTR, e->v.Attribute.attr, names);
|
ADDOP_NAME(c, LOAD_ATTR, e->v.Attribute.attr, names);
|
||||||
break;
|
break;
|
||||||
case AugStore:
|
|
||||||
ADDOP(c, ROT_TWO);
|
|
||||||
/* Fall through */
|
|
||||||
case Store:
|
case Store:
|
||||||
ADDOP_NAME(c, STORE_ATTR, e->v.Attribute.attr, names);
|
ADDOP_NAME(c, STORE_ATTR, e->v.Attribute.attr, names);
|
||||||
break;
|
break;
|
||||||
case Del:
|
case Del:
|
||||||
ADDOP_NAME(c, DELETE_ATTR, e->v.Attribute.attr, names);
|
ADDOP_NAME(c, DELETE_ATTR, e->v.Attribute.attr, names);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
PyErr_Format(PyExc_SystemError,
|
|
||||||
"expr_context kind %d should not be possible",
|
|
||||||
e->v.Attribute.ctx);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Subscript_kind:
|
case Subscript_kind:
|
||||||
|
@ -5088,48 +5035,58 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
|
||||||
static int
|
static int
|
||||||
compiler_augassign(struct compiler *c, stmt_ty s)
|
compiler_augassign(struct compiler *c, stmt_ty s)
|
||||||
{
|
{
|
||||||
expr_ty e = s->v.AugAssign.target;
|
|
||||||
expr_ty auge;
|
|
||||||
|
|
||||||
assert(s->kind == AugAssign_kind);
|
assert(s->kind == AugAssign_kind);
|
||||||
|
expr_ty e = s->v.AugAssign.target;
|
||||||
|
|
||||||
|
int old_lineno = c->u->u_lineno;
|
||||||
|
int old_col_offset = c->u->u_col_offset;
|
||||||
|
SET_LOC(c, e);
|
||||||
|
|
||||||
switch (e->kind) {
|
switch (e->kind) {
|
||||||
case Attribute_kind:
|
case Attribute_kind:
|
||||||
auge = Attribute(e->v.Attribute.value, e->v.Attribute.attr,
|
VISIT(c, expr, e->v.Attribute.value);
|
||||||
AugLoad, e->lineno, e->col_offset,
|
ADDOP(c, DUP_TOP);
|
||||||
e->end_lineno, e->end_col_offset, c->c_arena);
|
ADDOP_NAME(c, LOAD_ATTR, e->v.Attribute.attr, names);
|
||||||
if (auge == NULL)
|
|
||||||
return 0;
|
|
||||||
VISIT(c, expr, auge);
|
|
||||||
VISIT(c, expr, s->v.AugAssign.value);
|
|
||||||
ADDOP(c, inplace_binop(s->v.AugAssign.op));
|
|
||||||
auge->v.Attribute.ctx = AugStore;
|
|
||||||
VISIT(c, expr, auge);
|
|
||||||
break;
|
break;
|
||||||
case Subscript_kind:
|
case Subscript_kind:
|
||||||
auge = Subscript(e->v.Subscript.value, e->v.Subscript.slice,
|
VISIT(c, expr, e->v.Subscript.value);
|
||||||
AugLoad, e->lineno, e->col_offset,
|
VISIT(c, expr, e->v.Subscript.slice);
|
||||||
e->end_lineno, e->end_col_offset, c->c_arena);
|
ADDOP(c, DUP_TOP_TWO);
|
||||||
if (auge == NULL)
|
ADDOP(c, BINARY_SUBSCR);
|
||||||
return 0;
|
|
||||||
VISIT(c, expr, auge);
|
|
||||||
VISIT(c, expr, s->v.AugAssign.value);
|
|
||||||
ADDOP(c, inplace_binop(s->v.AugAssign.op));
|
|
||||||
auge->v.Subscript.ctx = AugStore;
|
|
||||||
VISIT(c, expr, auge);
|
|
||||||
break;
|
break;
|
||||||
case Name_kind:
|
case Name_kind:
|
||||||
if (!compiler_nameop(c, e->v.Name.id, Load))
|
if (!compiler_nameop(c, e->v.Name.id, Load))
|
||||||
return 0;
|
return 0;
|
||||||
VISIT(c, expr, s->v.AugAssign.value);
|
break;
|
||||||
ADDOP(c, inplace_binop(s->v.AugAssign.op));
|
|
||||||
return compiler_nameop(c, e->v.Name.id, Store);
|
|
||||||
default:
|
default:
|
||||||
PyErr_Format(PyExc_SystemError,
|
PyErr_Format(PyExc_SystemError,
|
||||||
"invalid node type (%d) for augmented assignment",
|
"invalid node type (%d) for augmented assignment",
|
||||||
e->kind);
|
e->kind);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c->u->u_lineno = old_lineno;
|
||||||
|
c->u->u_col_offset = old_col_offset;
|
||||||
|
|
||||||
|
VISIT(c, expr, s->v.AugAssign.value);
|
||||||
|
ADDOP(c, inplace_binop(s->v.AugAssign.op));
|
||||||
|
|
||||||
|
SET_LOC(c, e);
|
||||||
|
|
||||||
|
switch (e->kind) {
|
||||||
|
case Attribute_kind:
|
||||||
|
ADDOP(c, ROT_TWO);
|
||||||
|
ADDOP_NAME(c, STORE_ATTR, e->v.Attribute.attr, names);
|
||||||
|
break;
|
||||||
|
case Subscript_kind:
|
||||||
|
ADDOP(c, ROT_THREE);
|
||||||
|
ADDOP(c, STORE_SUBSCR);
|
||||||
|
break;
|
||||||
|
case Name_kind:
|
||||||
|
return compiler_nameop(c, e->v.Name.id, Store);
|
||||||
|
default:
|
||||||
|
Py_UNREACHABLE();
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5322,27 +5279,13 @@ compiler_subscript(struct compiler *c, expr_ty e)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ctx) {
|
switch (ctx) {
|
||||||
case AugLoad: /* fall through to Load */
|
|
||||||
case Load: op = BINARY_SUBSCR; break;
|
case Load: op = BINARY_SUBSCR; break;
|
||||||
case AugStore:/* fall through to Store */
|
|
||||||
case Store: op = STORE_SUBSCR; break;
|
case Store: op = STORE_SUBSCR; break;
|
||||||
case Del: op = DELETE_SUBSCR; break;
|
case Del: op = DELETE_SUBSCR; break;
|
||||||
default:
|
|
||||||
PyErr_Format(PyExc_SystemError,
|
|
||||||
"expr_context kind %d should not be possible",
|
|
||||||
ctx);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (ctx == AugStore) {
|
|
||||||
ADDOP(c, ROT_THREE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
VISIT(c, expr, e->v.Subscript.value);
|
|
||||||
VISIT(c, expr, e->v.Subscript.slice);
|
|
||||||
if (ctx == AugLoad) {
|
|
||||||
ADDOP(c, DUP_TOP_TWO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
assert(op);
|
||||||
|
VISIT(c, expr, e->v.Subscript.value);
|
||||||
|
VISIT(c, expr, e->v.Subscript.slice);
|
||||||
ADDOP(c, op);
|
ADDOP(c, op);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue