# HG changeset patch # User Adrian Buehlmann # Date 1336550330 -7200 # Node ID 1435866c1937bf2de3d23594bd7aca991eb1967b # Parent 3c738cb162bff9b9e5dc3cab409987d149fd7239 parser: use PyInt_FromSsize_t in index_stats Eliminates mercurial/parsers.c(515) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'long', possible loss of data mercurial/parsers.c(520) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'long', possible loss of data mercurial/parsers.c(521) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'long', possible loss of data when compiling for Windows x64 target using the Microsoft compiler. PyInt_FromSsize_t does not exist for Python 2.4 and earlier, so we define a fallback in util.h to use PyInt_FromLong when compiling for Python 2.4. diff -r 3c738cb162bf -r 1435866c1937 mercurial/parsers.c --- a/mercurial/parsers.c Fri May 11 10:53:12 2012 -0700 +++ b/mercurial/parsers.c Wed May 09 09:58:50 2012 +0200 @@ -508,13 +508,13 @@ return NULL; #define istat(__n, __d) \ - if (PyDict_SetItemString(obj, __d, PyInt_FromLong(self->__n)) == -1) \ + if (PyDict_SetItemString(obj, __d, PyInt_FromSsize_t(self->__n)) == -1) \ goto bail; if (self->added) { Py_ssize_t len = PyList_GET_SIZE(self->added); if (PyDict_SetItemString(obj, "index entries added", - PyInt_FromLong(len)) == -1) + PyInt_FromSsize_t(len)) == -1) goto bail; } diff -r 3c738cb162bf -r 1435866c1937 mercurial/util.h --- a/mercurial/util.h Fri May 11 10:53:12 2012 -0700 +++ b/mercurial/util.h Wed May 09 09:58:50 2012 +0200 @@ -109,6 +109,7 @@ typedef int Py_ssize_t; typedef Py_ssize_t (*lenfunc)(PyObject *); typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t); +#define PyInt_FromSsize_t PyInt_FromLong #if !defined(PY_SSIZE_T_MIN) #define PY_SSIZE_T_MAX INT_MAX