bpo-32550. Remove the STORE_ANNOTATION bytecode. (GH-5181)

This commit is contained in:
Mark Shannon 2018-01-30 00:41:04 +00:00 committed by Raymond Hettinger
parent b6e43af669
commit 332cd5ee4f
11 changed files with 147 additions and 199 deletions

View file

@ -1574,61 +1574,6 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
DISPATCH();
}
TARGET(STORE_ANNOTATION) {
_Py_IDENTIFIER(__annotations__);
PyObject *ann_dict;
PyObject *ann = POP();
PyObject *name = GETITEM(names, oparg);
int err;
if (f->f_locals == NULL) {
PyErr_Format(PyExc_SystemError,
"no locals found when storing annotation");
Py_DECREF(ann);
goto error;
}
/* first try to get __annotations__ from locals... */
if (PyDict_CheckExact(f->f_locals)) {
ann_dict = _PyDict_GetItemId(f->f_locals,
&PyId___annotations__);
if (ann_dict == NULL) {
PyErr_SetString(PyExc_NameError,
"__annotations__ not found");
Py_DECREF(ann);
goto error;
}
Py_INCREF(ann_dict);
}
else {
PyObject *ann_str = _PyUnicode_FromId(&PyId___annotations__);
if (ann_str == NULL) {
Py_DECREF(ann);
goto error;
}
ann_dict = PyObject_GetItem(f->f_locals, ann_str);
if (ann_dict == NULL) {
if (PyErr_ExceptionMatches(PyExc_KeyError)) {
PyErr_SetString(PyExc_NameError,
"__annotations__ not found");
}
Py_DECREF(ann);
goto error;
}
}
/* ...if succeeded, __annotations__[name] = ann */
if (PyDict_CheckExact(ann_dict)) {
err = PyDict_SetItem(ann_dict, name, ann);
}
else {
err = PyObject_SetItem(ann_dict, name, ann);
}
Py_DECREF(ann_dict);
Py_DECREF(ann);
if (err != 0) {
goto error;
}
DISPATCH();
}
TARGET(DELETE_SUBSCR) {
PyObject *sub = TOP();
PyObject *container = SECOND();