mirror of
https://github.com/python/cpython.git
synced 2025-12-10 02:50:09 +00:00
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
This commit is contained in:
parent
a65f802692
commit
470a0a68eb
11 changed files with 34 additions and 32 deletions
|
|
@ -3190,7 +3190,7 @@ _PyList_AsTupleAndClear(PyListObject *self)
|
|||
}
|
||||
|
||||
PyObject *
|
||||
_PyList_FromStackRefSteal(const _PyStackRef *src, Py_ssize_t n)
|
||||
_PyList_FromStackRefStealOnSuccess(const _PyStackRef *src, Py_ssize_t n)
|
||||
{
|
||||
if (n == 0) {
|
||||
return PyList_New(0);
|
||||
|
|
@ -3198,9 +3198,6 @@ _PyList_FromStackRefSteal(const _PyStackRef *src, Py_ssize_t n)
|
|||
|
||||
PyListObject *list = (PyListObject *)PyList_New(n);
|
||||
if (list == NULL) {
|
||||
for (Py_ssize_t i = 0; i < n; i++) {
|
||||
PyStackRef_CLOSE(src[i]);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue