aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/executor_cases.c.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2025-01-22 10:51:37 +0000
committerGitHub <noreply@github.com>2025-01-22 10:51:37 +0000
commit470a0a68ebbbb4254f1a3e8e22cce0c3a0827055 (patch)
tree27f602ce33d9c7701db07ad64fb0342c8f49a65a /Python/executor_cases.c.h
parenta65f802692bd04e1ad18e467d4ccb033b049c2a7 (diff)
downloadcpython-470a0a68ebbbb4254f1a3e8e22cce0c3a0827055.tar.gz
cpython-470a0a68ebbbb4254f1a3e8e22cce0c3a0827055.zip
GH-128682: Change a couple of functions to only steal references on success. (GH-129132)
Change PyTuple_FromStackRefSteal and PyList_FromStackRefSteal to only steal on success to avoid escaping
Diffstat (limited to 'Python/executor_cases.c.h')
-rw-r--r--Python/executor_cases.c.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index 93072304e6e..d2da9a8acf9 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -2240,8 +2240,10 @@
_PyStackRef tup;
oparg = CURRENT_OPARG();
values = &stack_pointer[-oparg];
- PyObject *tup_o = _PyTuple_FromStackRefSteal(values, oparg);
- if (tup_o == NULL) JUMP_TO_ERROR();
+ PyObject *tup_o = _PyTuple_FromStackRefStealOnSuccess(values, oparg);
+ if (tup_o == NULL) {
+ JUMP_TO_ERROR();
+ }
tup = PyStackRef_FromPyObjectSteal(tup_o);
stack_pointer[-oparg] = tup;
stack_pointer += 1 - oparg;
@@ -2254,8 +2256,10 @@
_PyStackRef list;
oparg = CURRENT_OPARG();
values = &stack_pointer[-oparg];
- PyObject *list_o = _PyList_FromStackRefSteal(values, oparg);
- if (list_o == NULL) JUMP_TO_ERROR();
+ PyObject *list_o = _PyList_FromStackRefStealOnSuccess(values, oparg);
+ if (list_o == NULL) {
+ JUMP_TO_ERROR();
+ }
list = PyStackRef_FromPyObjectSteal(list_o);
stack_pointer[-oparg] = list;
stack_pointer += 1 - oparg;