Skip to content

Commit

Permalink
pythongh-117139: Fix a few wrong steals in bytecodes.c (pythonGH-121127)
Browse files Browse the repository at this point in the history
Fix a few wrong steals in bytecodes.c
  • Loading branch information
Fidget-Spinner authored and estyxx committed Jul 17, 2024
1 parent 7cf2558 commit 5900647
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
16 changes: 8 additions & 8 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
32 changes: 16 additions & 16 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5900647

Please sign in to comment.