Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit db3a8a5

Browse files
colesburyFidget-Spinner
authored andcommittedAug 22, 2024
pythongh-117139: Fix a few _PyStackRef related bugs (python#122831)
`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>
1 parent 5ab99d5 commit db3a8a5

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed
 

‎Python/bytecodes.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -1714,11 +1714,10 @@ dummy_func(
17141714
}
17151715
int err = 0;
17161716
for (int i = 0; i < oparg; i++) {
1717-
PyObject *item = PyStackRef_AsPyObjectSteal(values[i]);
17181717
if (err == 0) {
1719-
err = PySet_Add(set_o, item);
1718+
err = PySet_Add(set_o, PyStackRef_AsPyObjectBorrow(values[i]));
17201719
}
1721-
Py_DECREF(item);
1720+
PyStackRef_CLOSE(values[i]);
17221721
}
17231722
if (err != 0) {
17241723
Py_DECREF(set_o);
@@ -3235,7 +3234,10 @@ dummy_func(
32353234
/* Callable is not a normal Python function */
32363235
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
32373236
if (CONVERSION_FAILED(args_o)) {
3238-
DECREF_INPUTS();
3237+
PyStackRef_CLOSE(callable);
3238+
for (int i = 0; i < total_args; i++) {
3239+
PyStackRef_CLOSE(args[i]);
3240+
}
32393241
ERROR_IF(true, error);
32403242
}
32413243
PyObject *res_o = PyObject_Vectorcall(

‎Python/executor_cases.c.h

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Python/generated_cases.c.h

+6-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.