diff options
author | Mark Shannon <mark@hotpy.org> | 2021-10-18 08:57:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 08:57:24 (GMT) |
commit | 70945d57e775b335eb58b734d82e68484063e835 (patch) | |
tree | a8ce452431e8db3c44f3cc6ebb7845a420b60b1a /Objects/tupleobject.c | |
parent | fd03917786a9036ee87b7df604dfb260cc2420c9 (diff) | |
download | cpython-70945d57e775b335eb58b734d82e68484063e835.zip cpython-70945d57e775b335eb58b734d82e68484063e835.tar.gz cpython-70945d57e775b335eb58b734d82e68484063e835.tar.bz2 |
bpo-45256: Avoid C calls for most Python to Python calls. (GH-28937)
* Avoid making C calls for most calls to Python functions.
* Change initialize_locals(steal=true) and _PyTuple_FromArraySteal to consume the argument references regardless of whether they succeed or fail.
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r-- | Objects/tupleobject.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 018e738..0516830 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -490,9 +490,11 @@ _PyTuple_FromArraySteal(PyObject *const *src, Py_ssize_t n) if (n == 0) { return tuple_get_empty(); } - PyTupleObject *tuple = tuple_alloc(n); if (tuple == NULL) { + for (Py_ssize_t i = 0; i < n; i++) { + Py_DECREF(src[i]); + } return NULL; } PyObject **dst = tuple->ob_item; |