diff options
-rw-r--r-- | Objects/stringlib/partition.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Objects/stringlib/partition.h b/Objects/stringlib/partition.h index 40cb512..ed32a6f 100644 --- 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()) { + Py_DECREF(out); + return NULL; + } #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()) { + Py_DECREF(out); + return NULL; + } #else Py_INCREF(STRINGLIB_EMPTY); PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY); |