From patchwork Sat Mar 3 13:27:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [07, of, 11] cext: fix computephasesmapsets() not to return without setting an exception From: Yuya Nishihara X-Patchwork-Id: 28773 Message-Id: <0ceb34d59bec1e851246.1520083660@mimosa> To: mercurial-devel@mercurial-scm.org Date: Sat, 03 Mar 2018 08:27:40 -0500 # HG changeset patch # User Yuya Nishihara # Date 1520078222 18000 # Sat Mar 03 06:57:02 2018 -0500 # Node ID 0ceb34d59bec1e8512461f2479c7fe5024a85422 # Parent 87b0df6c39fff3ac758a52a9b0b95bca1f61187c cext: fix computephasesmapsets() not to return without setting an exception Spotted by map() of Python 3. diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c +++ b/mercurial/cext/revlog.c @@ -643,8 +643,10 @@ static PyObject *compute_phases_map_sets if (!PyArg_ParseTuple(args, "O", &roots)) goto done; - if (roots == NULL || !PyList_Check(roots)) + if (roots == NULL || !PyList_Check(roots)) { + PyErr_SetString(PyExc_TypeError, "roots must be a list"); goto done; + } phases = calloc(len, 1); /* phase per rev: {0: public, 1: draft, 2: secret} */ if (phases == NULL) { @@ -667,8 +669,11 @@ static PyObject *compute_phases_map_sets if (phaseset == NULL) goto release; PyList_SET_ITEM(phasessetlist, i+1, phaseset); - if (!PyList_Check(phaseroots)) + if (!PyList_Check(phaseroots)) { + PyErr_SetString(PyExc_TypeError, + "roots item must be a list"); goto release; + } minrevphase = add_roots_get_min(self, phaseroots, i+1, phases); if (minrevphase == -2) /* Error from add_roots_get_min */ goto release;