changeset 36623:a472a897c340

cext: fix computephasesmapsets() not to return without setting an exception Spotted by map() of Python 3.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Mar 2018 06:57:02 -0500
parents 0297f9c4caee
children 3118766266ae
files mercurial/cext/revlog.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/revlog.c	Sat Mar 03 06:44:47 2018 -0500
+++ b/mercurial/cext/revlog.c	Sat Mar 03 06:57:02 2018 -0500
@@ -643,8 +643,10 @@
 
 	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 @@
 		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;