[PATCH] parsers: fix two cases of unsigned long instead of Py_ssize_t

Augie Fackler raf at durin42.com
Wed Aug 26 14:21:50 UTC 2015


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1440598807 14400
#      Wed Aug 26 10:20:07 2015 -0400
# Node ID f7c929553d447dec9aa3df923c6e90faf9b9fd57
# Parent  05e7f57c74ac5b556b49870af86f61aa0c54babb
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.

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -1046,13 +1046,12 @@ static PyObject *list_copy(PyObject *lis
 	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;
 		}
@@ -2666,12 +2665,10 @@ bail:
 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;


More information about the Mercurial-devel mailing list