Kaydet (Commit) cc64eb5b authored tarafından Victor Stinner's avatar Victor Stinner

Issue #18408: Fix bytearrayiter.partition()/rpartition(), handle

PyByteArray_FromStringAndSize() failure (ex: on memory allocation failure)
üst 986e224d
...@@ -29,6 +29,11 @@ STRINGLIB(partition)(PyObject* str_obj, ...@@ -29,6 +29,11 @@ STRINGLIB(partition)(PyObject* str_obj,
PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len)); PyTuple_SET_ITEM(out, 0, STRINGLIB_NEW(str, str_len));
PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0));
PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0)); PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(NULL, 0));
if (PyErr_Occurred()) {
Py_DECREF(out);
return NULL;
}
#else #else
Py_INCREF(str_obj); Py_INCREF(str_obj);
PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj);
...@@ -79,6 +84,11 @@ STRINGLIB(rpartition)(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, 0, STRINGLIB_NEW(NULL, 0));
PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0)); PyTuple_SET_ITEM(out, 1, STRINGLIB_NEW(NULL, 0));
PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len)); PyTuple_SET_ITEM(out, 2, STRINGLIB_NEW(str, str_len));
if (PyErr_Occurred()) {
Py_DECREF(out);
return NULL;
}
#else #else
Py_INCREF(STRINGLIB_EMPTY); Py_INCREF(STRINGLIB_EMPTY);
PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY); PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment