comparison mercurial/parsers.c @ 26107:50582df9d7a7

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.
author Augie Fackler <augie@google.com>
date Wed, 26 Aug 2015 10:20:07 -0400
parents ce26928cbe41
children 4d6cdea33f37
comparison
equal deleted inserted replaced
26106:c568c4db036f 26107:50582df9d7a7
1044 } 1044 }
1045 1045
1046 return newlist; 1046 return newlist;
1047 } 1047 }
1048 1048
1049 /* arg should be Py_ssize_t but Python 2.4 do not support the n format */ 1049 static int check_filter(PyObject *filter, Py_ssize_t arg) {
1050 static int check_filter(PyObject *filter, unsigned long arg) {
1051 if (filter) { 1050 if (filter) {
1052 PyObject *arglist, *result; 1051 PyObject *arglist, *result;
1053 int isfiltered; 1052 int isfiltered;
1054 1053
1055 arglist = Py_BuildValue("(k)", arg); 1054 arglist = Py_BuildValue("(n)", arg);
1056 if (!arglist) { 1055 if (!arglist) {
1057 return -1; 1056 return -1;
1058 } 1057 }
1059 1058
1060 result = PyEval_CallObject(filter, arglist); 1059 result = PyEval_CallObject(filter, arglist);
2663 2662
2664 2663
2665 static PyObject *fm1readmarkers(PyObject *self, PyObject *args) { 2664 static PyObject *fm1readmarkers(PyObject *self, PyObject *args) {
2666 const char *data; 2665 const char *data;
2667 Py_ssize_t datalen; 2666 Py_ssize_t datalen;
2668 /* only unsigned long because python 2.4, should be Py_ssize_t */ 2667 Py_ssize_t offset, stop;
2669 unsigned long offset, stop;
2670 PyObject *markers = NULL; 2668 PyObject *markers = NULL;
2671 2669
2672 /* replace kk with nn when we drop Python 2.4 */ 2670 if (!PyArg_ParseTuple(args, "s#nn", &data, &datalen, &offset, &stop)) {
2673 if (!PyArg_ParseTuple(args, "s#kk", &data, &datalen, &offset, &stop)) {
2674 return NULL; 2671 return NULL;
2675 } 2672 }
2676 data += offset; 2673 data += offset;
2677 markers = PyList_New(0); 2674 markers = PyList_New(0);
2678 if (!markers) { 2675 if (!markers) {