cpython: 9d9371d4ff7b (original) (raw)
Mercurial > cpython
changeset 86721:9d9371d4ff7b
Issue #18408: Fix bytearrayiter.partition()/rpartition(), handle PyByteArray_FromStringAndSize() failure (ex: on memory allocation failure) [#18408]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Tue, 29 Oct 2013 03:15:37 +0100 |
parents | 549cd815bf8d |
children | 20cd15a28ad3 |
files | Objects/stringlib/partition.h |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-)[+] [-] Objects/stringlib/partition.h 10 |
line wrap: on
line diff
--- a/Objects/stringlib/partition.h +++ b/Objects/stringlib/partition.h @@ -29,6 +29,11 @@ STRINGLIB(partition)(PyObject* str_obj, PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len)); PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0)); +
if (PyErr_Occurred()) {[](#l1.8)
Py_DECREF(out);[](#l1.9)
return NULL;[](#l1.10)
}[](#l1.11)
#else Py_INCREF(str_obj); PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); @@ -79,6 +84,11 @@ STRINGLIB(rpartition)(PyObject* str_obj, PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(NULL, 0)); PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len)); +
if (PyErr_Occurred()) {[](#l1.20)
Py_DECREF(out);[](#l1.21)
return NULL;[](#l1.22)
}[](#l1.23)
#else Py_INCREF(STRINGLIB_EMPTY); PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY);