]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
ceval: Use _PyTuple_FromArraySteal in BUILD_TUPLE (GH-96516)
authorKevin Modzelewski <kmod@users.noreply.github.com>
Wed, 14 Sep 2022 03:44:32 +0000 (23:44 -0400)
committerGitHub <noreply@github.com>
Wed, 14 Sep 2022 03:44:32 +0000 (12:44 +0900)
Python/ceval.c

index 091b0eb76407b415336b11d66f29bd4835881998..1cf72461f4cf5770decf49e9897bb4f15504176b 100644 (file)
@@ -2650,13 +2650,10 @@ handle_eval_breaker:
         }
 
         TARGET(BUILD_TUPLE) {
-            PyObject *tup = PyTuple_New(oparg);
+            STACK_SHRINK(oparg);
+            PyObject *tup = _PyTuple_FromArraySteal(stack_pointer, oparg);
             if (tup == NULL)
                 goto error;
-            while (--oparg >= 0) {
-                PyObject *item = POP();
-                PyTuple_SET_ITEM(tup, oparg, item);
-            }
             PUSH(tup);
             DISPATCH();
         }