mirror of https://github.com/python/cpython
gh-117139: Fix a few wrong steals in bytecodes.c (GH-121127)
Fix a few wrong steals in bytecodes.c
This commit is contained in:
parent
2894aa14f2
commit
e6543daf12
|
@ -230,7 +230,7 @@ dummy_func(
|
|||
}
|
||||
|
||||
replicate(8) pure inst(LOAD_FAST, (-- value)) {
|
||||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL);
|
||||
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
|
||||
value = PyStackRef_DUP(GETLOCAL(oparg));
|
||||
}
|
||||
|
||||
|
@ -673,7 +673,7 @@ dummy_func(
|
|||
err = 1;
|
||||
}
|
||||
else {
|
||||
err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), slice, PyStackRef_AsPyObjectSteal(v));
|
||||
err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), slice, PyStackRef_AsPyObjectBorrow(v));
|
||||
Py_DECREF(slice);
|
||||
}
|
||||
PyStackRef_CLOSE(v);
|
||||
|
@ -789,7 +789,7 @@ dummy_func(
|
|||
|
||||
inst(SET_ADD, (set, unused[oparg-1], v -- set, unused[oparg-1])) {
|
||||
int err = PySet_Add(PyStackRef_AsPyObjectBorrow(set),
|
||||
PyStackRef_AsPyObjectSteal(v));
|
||||
PyStackRef_AsPyObjectBorrow(v));
|
||||
DECREF_INPUTS();
|
||||
ERROR_IF(err, error);
|
||||
}
|
||||
|
@ -813,7 +813,7 @@ dummy_func(
|
|||
|
||||
op(_STORE_SUBSCR, (v, container, sub -- )) {
|
||||
/* container[sub] = v */
|
||||
int err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), PyStackRef_AsPyObjectSteal(sub), PyStackRef_AsPyObjectSteal(v));
|
||||
int err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), PyStackRef_AsPyObjectBorrow(sub), PyStackRef_AsPyObjectBorrow(v));
|
||||
DECREF_INPUTS();
|
||||
ERROR_IF(err, error);
|
||||
}
|
||||
|
@ -1235,7 +1235,7 @@ dummy_func(
|
|||
inst(POP_EXCEPT, (exc_value -- )) {
|
||||
_PyErr_StackItem *exc_info = tstate->exc_info;
|
||||
Py_XSETREF(exc_info->exc_value,
|
||||
PyStackRef_AsPyObjectBorrow(exc_value) == Py_None
|
||||
PyStackRef_Is(exc_value, PyStackRef_None)
|
||||
? NULL : PyStackRef_AsPyObjectSteal(exc_value));
|
||||
}
|
||||
|
||||
|
@ -1330,9 +1330,9 @@ dummy_func(
|
|||
ERROR_IF(true, error);
|
||||
}
|
||||
if (PyDict_CheckExact(ns))
|
||||
err = PyDict_SetItem(ns, name, PyStackRef_AsPyObjectSteal(v));
|
||||
err = PyDict_SetItem(ns, name, PyStackRef_AsPyObjectBorrow(v));
|
||||
else
|
||||
err = PyObject_SetItem(ns, name, PyStackRef_AsPyObjectSteal(v));
|
||||
err = PyObject_SetItem(ns, name, PyStackRef_AsPyObjectBorrow(v));
|
||||
DECREF_INPUTS();
|
||||
ERROR_IF(err, error);
|
||||
}
|
||||
|
@ -1450,7 +1450,7 @@ dummy_func(
|
|||
op(_STORE_ATTR, (v, owner --)) {
|
||||
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
|
||||
int err = PyObject_SetAttr(PyStackRef_AsPyObjectBorrow(owner),
|
||||
name, PyStackRef_AsPyObjectSteal(v));
|
||||
name, PyStackRef_AsPyObjectBorrow(v));
|
||||
DECREF_INPUTS();
|
||||
ERROR_IF(err, error);
|
||||
}
|
||||
|
|
|
@ -1619,7 +1619,7 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func,
|
|||
goto kw_fail;
|
||||
}
|
||||
|
||||
if (PyDict_SetItem(kwdict, keyword, PyStackRef_AsPyObjectSteal(value_stackref)) == -1) {
|
||||
if (PyDict_SetItem(kwdict, keyword, PyStackRef_AsPyObjectBorrow(value_stackref)) == -1) {
|
||||
goto kw_fail;
|
||||
}
|
||||
PyStackRef_CLOSE(value_stackref);
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
_PyStackRef value;
|
||||
oparg = 0;
|
||||
assert(oparg == CURRENT_OPARG());
|
||||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL);
|
||||
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
|
||||
value = PyStackRef_DUP(GETLOCAL(oparg));
|
||||
stack_pointer[0] = value;
|
||||
stack_pointer += 1;
|
||||
|
@ -66,7 +66,7 @@
|
|||
_PyStackRef value;
|
||||
oparg = 1;
|
||||
assert(oparg == CURRENT_OPARG());
|
||||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL);
|
||||
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
|
||||
value = PyStackRef_DUP(GETLOCAL(oparg));
|
||||
stack_pointer[0] = value;
|
||||
stack_pointer += 1;
|
||||
|
@ -78,7 +78,7 @@
|
|||
_PyStackRef value;
|
||||
oparg = 2;
|
||||
assert(oparg == CURRENT_OPARG());
|
||||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL);
|
||||
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
|
||||
value = PyStackRef_DUP(GETLOCAL(oparg));
|
||||
stack_pointer[0] = value;
|
||||
stack_pointer += 1;
|
||||
|
@ -90,7 +90,7 @@
|
|||
_PyStackRef value;
|
||||
oparg = 3;
|
||||
assert(oparg == CURRENT_OPARG());
|
||||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL);
|
||||
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
|
||||
value = PyStackRef_DUP(GETLOCAL(oparg));
|
||||
stack_pointer[0] = value;
|
||||
stack_pointer += 1;
|
||||
|
@ -102,7 +102,7 @@
|
|||
_PyStackRef value;
|
||||
oparg = 4;
|
||||
assert(oparg == CURRENT_OPARG());
|
||||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL);
|
||||
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
|
||||
value = PyStackRef_DUP(GETLOCAL(oparg));
|
||||
stack_pointer[0] = value;
|
||||
stack_pointer += 1;
|
||||
|
@ -114,7 +114,7 @@
|
|||
_PyStackRef value;
|
||||
oparg = 5;
|
||||
assert(oparg == CURRENT_OPARG());
|
||||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL);
|
||||
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
|
||||
value = PyStackRef_DUP(GETLOCAL(oparg));
|
||||
stack_pointer[0] = value;
|
||||
stack_pointer += 1;
|
||||
|
@ -126,7 +126,7 @@
|
|||
_PyStackRef value;
|
||||
oparg = 6;
|
||||
assert(oparg == CURRENT_OPARG());
|
||||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL);
|
||||
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
|
||||
value = PyStackRef_DUP(GETLOCAL(oparg));
|
||||
stack_pointer[0] = value;
|
||||
stack_pointer += 1;
|
||||
|
@ -138,7 +138,7 @@
|
|||
_PyStackRef value;
|
||||
oparg = 7;
|
||||
assert(oparg == CURRENT_OPARG());
|
||||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL);
|
||||
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
|
||||
value = PyStackRef_DUP(GETLOCAL(oparg));
|
||||
stack_pointer[0] = value;
|
||||
stack_pointer += 1;
|
||||
|
@ -149,7 +149,7 @@
|
|||
case _LOAD_FAST: {
|
||||
_PyStackRef value;
|
||||
oparg = CURRENT_OPARG();
|
||||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL);
|
||||
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
|
||||
value = PyStackRef_DUP(GETLOCAL(oparg));
|
||||
stack_pointer[0] = value;
|
||||
stack_pointer += 1;
|
||||
|
@ -757,7 +757,7 @@
|
|||
err = 1;
|
||||
}
|
||||
else {
|
||||
err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), slice, PyStackRef_AsPyObjectSteal(v));
|
||||
err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), slice, PyStackRef_AsPyObjectBorrow(v));
|
||||
Py_DECREF(slice);
|
||||
}
|
||||
PyStackRef_CLOSE(v);
|
||||
|
@ -939,7 +939,7 @@
|
|||
v = stack_pointer[-1];
|
||||
set = stack_pointer[-2 - (oparg-1)];
|
||||
int err = PySet_Add(PyStackRef_AsPyObjectBorrow(set),
|
||||
PyStackRef_AsPyObjectSteal(v));
|
||||
PyStackRef_AsPyObjectBorrow(v));
|
||||
PyStackRef_CLOSE(v);
|
||||
if (err) JUMP_TO_ERROR();
|
||||
stack_pointer += -1;
|
||||
|
@ -955,7 +955,7 @@
|
|||
container = stack_pointer[-2];
|
||||
v = stack_pointer[-3];
|
||||
/* container[sub] = v */
|
||||
int err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), PyStackRef_AsPyObjectSteal(sub), PyStackRef_AsPyObjectSteal(v));
|
||||
int err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), PyStackRef_AsPyObjectBorrow(sub), PyStackRef_AsPyObjectBorrow(v));
|
||||
PyStackRef_CLOSE(v);
|
||||
PyStackRef_CLOSE(container);
|
||||
PyStackRef_CLOSE(sub);
|
||||
|
@ -1281,7 +1281,7 @@
|
|||
exc_value = stack_pointer[-1];
|
||||
_PyErr_StackItem *exc_info = tstate->exc_info;
|
||||
Py_XSETREF(exc_info->exc_value,
|
||||
PyStackRef_AsPyObjectBorrow(exc_value) == Py_None
|
||||
PyStackRef_Is(exc_value, PyStackRef_None)
|
||||
? NULL : PyStackRef_AsPyObjectSteal(exc_value));
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
|
@ -1338,9 +1338,9 @@
|
|||
if (true) JUMP_TO_ERROR();
|
||||
}
|
||||
if (PyDict_CheckExact(ns))
|
||||
err = PyDict_SetItem(ns, name, PyStackRef_AsPyObjectSteal(v));
|
||||
err = PyDict_SetItem(ns, name, PyStackRef_AsPyObjectBorrow(v));
|
||||
else
|
||||
err = PyObject_SetItem(ns, name, PyStackRef_AsPyObjectSteal(v));
|
||||
err = PyObject_SetItem(ns, name, PyStackRef_AsPyObjectBorrow(v));
|
||||
PyStackRef_CLOSE(v);
|
||||
if (err) JUMP_TO_ERROR();
|
||||
stack_pointer += -1;
|
||||
|
@ -1483,7 +1483,7 @@
|
|||
v = stack_pointer[-2];
|
||||
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
|
||||
int err = PyObject_SetAttr(PyStackRef_AsPyObjectBorrow(owner),
|
||||
name, PyStackRef_AsPyObjectSteal(v));
|
||||
name, PyStackRef_AsPyObjectBorrow(v));
|
||||
PyStackRef_CLOSE(v);
|
||||
PyStackRef_CLOSE(owner);
|
||||
if (err) JUMP_TO_ERROR();
|
||||
|
|
|
@ -4667,7 +4667,7 @@
|
|||
next_instr += 1;
|
||||
INSTRUCTION_STATS(LOAD_FAST);
|
||||
_PyStackRef value;
|
||||
assert(PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg)) != NULL);
|
||||
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
|
||||
value = PyStackRef_DUP(GETLOCAL(oparg));
|
||||
stack_pointer[0] = value;
|
||||
stack_pointer += 1;
|
||||
|
@ -5359,7 +5359,7 @@
|
|||
exc_value = stack_pointer[-1];
|
||||
_PyErr_StackItem *exc_info = tstate->exc_info;
|
||||
Py_XSETREF(exc_info->exc_value,
|
||||
PyStackRef_AsPyObjectBorrow(exc_value) == Py_None
|
||||
PyStackRef_Is(exc_value, PyStackRef_None)
|
||||
? NULL : PyStackRef_AsPyObjectSteal(exc_value));
|
||||
stack_pointer += -1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
|
@ -5876,7 +5876,7 @@
|
|||
v = stack_pointer[-1];
|
||||
set = stack_pointer[-2 - (oparg-1)];
|
||||
int err = PySet_Add(PyStackRef_AsPyObjectBorrow(set),
|
||||
PyStackRef_AsPyObjectSteal(v));
|
||||
PyStackRef_AsPyObjectBorrow(v));
|
||||
PyStackRef_CLOSE(v);
|
||||
if (err) goto pop_1_error;
|
||||
stack_pointer += -1;
|
||||
|
@ -5977,7 +5977,7 @@
|
|||
{
|
||||
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
|
||||
int err = PyObject_SetAttr(PyStackRef_AsPyObjectBorrow(owner),
|
||||
name, PyStackRef_AsPyObjectSteal(v));
|
||||
name, PyStackRef_AsPyObjectBorrow(v));
|
||||
PyStackRef_CLOSE(v);
|
||||
PyStackRef_CLOSE(owner);
|
||||
if (err) goto pop_2_error;
|
||||
|
@ -6215,9 +6215,9 @@
|
|||
if (true) goto pop_1_error;
|
||||
}
|
||||
if (PyDict_CheckExact(ns))
|
||||
err = PyDict_SetItem(ns, name, PyStackRef_AsPyObjectSteal(v));
|
||||
err = PyDict_SetItem(ns, name, PyStackRef_AsPyObjectBorrow(v));
|
||||
else
|
||||
err = PyObject_SetItem(ns, name, PyStackRef_AsPyObjectSteal(v));
|
||||
err = PyObject_SetItem(ns, name, PyStackRef_AsPyObjectBorrow(v));
|
||||
PyStackRef_CLOSE(v);
|
||||
if (err) goto pop_1_error;
|
||||
stack_pointer += -1;
|
||||
|
@ -6244,7 +6244,7 @@
|
|||
err = 1;
|
||||
}
|
||||
else {
|
||||
err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), slice, PyStackRef_AsPyObjectSteal(v));
|
||||
err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), slice, PyStackRef_AsPyObjectBorrow(v));
|
||||
Py_DECREF(slice);
|
||||
}
|
||||
PyStackRef_CLOSE(v);
|
||||
|
@ -6285,7 +6285,7 @@
|
|||
v = stack_pointer[-3];
|
||||
{
|
||||
/* container[sub] = v */
|
||||
int err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), PyStackRef_AsPyObjectSteal(sub), PyStackRef_AsPyObjectSteal(v));
|
||||
int err = PyObject_SetItem(PyStackRef_AsPyObjectBorrow(container), PyStackRef_AsPyObjectBorrow(sub), PyStackRef_AsPyObjectBorrow(v));
|
||||
PyStackRef_CLOSE(v);
|
||||
PyStackRef_CLOSE(container);
|
||||
PyStackRef_CLOSE(sub);
|
||||
|
|
Loading…
Reference in New Issue