Skip to content

Commit

Permalink
pythongh-117139: Fix a few _PyStackRef related bugs (python#122831)
Browse files Browse the repository at this point in the history
`BUILD_SET` should use a borrow instead of a steal. The cleanup in `_DO_CALL`
`CONVERSION_FAILED` was incorrect.

Co-authored-by: Ken Jin <kenjin@python.org>
  • Loading branch information
2 people authored and blhsing committed Aug 22, 2024
1 parent 5ab99d5 commit db3a8a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
10 changes: 6 additions & 4 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1714,11 +1714,10 @@ dummy_func(
}
int err = 0;
for (int i = 0; i < oparg; i++) {
PyObject *item = PyStackRef_AsPyObjectSteal(values[i]);
if (err == 0) {
err = PySet_Add(set_o, item);
err = PySet_Add(set_o, PyStackRef_AsPyObjectBorrow(values[i]));
}
Py_DECREF(item);
PyStackRef_CLOSE(values[i]);
}
if (err != 0) {
Py_DECREF(set_o);
Expand Down Expand Up @@ -3235,7 +3234,10 @@ dummy_func(
/* Callable is not a normal Python function */
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
if (CONVERSION_FAILED(args_o)) {
DECREF_INPUTS();
PyStackRef_CLOSE(callable);
for (int i = 0; i < total_args; i++) {
PyStackRef_CLOSE(args[i]);
}
ERROR_IF(true, error);
}
PyObject *res_o = PyObject_Vectorcall(
Expand Down
5 changes: 2 additions & 3 deletions Python/executor_cases.c.h

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

15 changes: 6 additions & 9 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 db3a8a5

Please sign in to comment.