[PATCH 1 of 2 stable] WHAT: PyExc_TypeError in parsers.c is lost - use PyExc_ValueError instead

Mads Kiilerich mads at kiilerich.com
Sun Oct 19 21:56:49 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1413773777 -7200
#      Mon Oct 20 04:56:17 2014 +0200
# Branch stable
# Node ID 2ee3d9d0bc7be9b67f5f5f05db6faa2a9d927e2a
# Parent  c1ae0b2c1719f56b906472efea8b20ca0774c968
WHAT: PyExc_TypeError in parsers.c is lost - use PyExc_ValueError instead

This gives a reasonable and helpful error on Python 2.4:
+    File "$HGTMP/install/lib/python/mercurial/changelog.py", line 175, in headrevs
+      return self.index.headrevs(self.filteredrevs)
+  ValueError: unable to check filter
+  [1]
With TypeError the exception is lost and the code will continue but misbehave.
In the tests it shows as test-glog.t failing in weird ways. Python 2.7.8 also
seems to ignore TypeError here.

This doesn't make sense and we should figure out what really is going on, but
it helps pointing out why test-glog.t is failing on Python 2.4.

No other tests are failing even though index.headrevs terminates with an error
that is ignored. That suggests that we have insufficient test coverage of the
headrevs code.

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -950,7 +950,7 @@ static PyObject *index_headrevs(indexObj
 
 		isfiltered = check_filter(filter, i);
 		if (isfiltered == -1) {
-			PyErr_SetString(PyExc_TypeError,
+			PyErr_SetString(PyExc_ValueError,
 				"unable to check filter");
 			goto bail;
 		}


More information about the Mercurial-devel mailing list