parsers: fix two cases of unsigned long instead of Py_ssize_t
authorAugie Fackler <augie@google.com>
Wed, 26 Aug 2015 10:20:07 -0400
changeset 26107 50582df9d7a7
parent 26106 c568c4db036f
child 26108 05306b9359d3
parsers: fix two cases of unsigned long instead of Py_ssize_t We had to do this before because Python 2.4 didn't understand the n format specifier in Py_BuildValue and friends. We no longer have that problem.
mercurial/parsers.c
--- a/mercurial/parsers.c	Sat Jul 04 16:07:42 2015 +0900
+++ b/mercurial/parsers.c	Wed Aug 26 10:20:07 2015 -0400
@@ -1046,13 +1046,12 @@
 	return newlist;
 }
 
-/* arg should be Py_ssize_t but Python 2.4 do not support the n format */
-static int check_filter(PyObject *filter, unsigned long arg) {
+static int check_filter(PyObject *filter, Py_ssize_t arg) {
 	if (filter) {
 		PyObject *arglist, *result;
 		int isfiltered;
 
-		arglist = Py_BuildValue("(k)", arg);
+		arglist = Py_BuildValue("(n)", arg);
 		if (!arglist) {
 			return -1;
 		}
@@ -2665,12 +2664,10 @@
 static PyObject *fm1readmarkers(PyObject *self, PyObject *args) {
 	const char *data;
 	Py_ssize_t datalen;
-	/* only unsigned long because python 2.4, should be Py_ssize_t */
-	unsigned long offset, stop;
+	Py_ssize_t offset, stop;
 	PyObject *markers = NULL;
 
-	/* replace kk with nn when we drop Python 2.4 */
-	if (!PyArg_ParseTuple(args, "s#kk", &data, &datalen, &offset, &stop)) {
+	if (!PyArg_ParseTuple(args, "s#nn", &data, &datalen, &offset, &stop)) {
 		return NULL;
 	}
 	data += offset;