Mercurial > hg
changeset 42068:896b19d12c08
cext: make parsers.c PY_SSIZE_T_CLEAN
This is needed to avoid a deprecation warning in Python 3.8. I believe
the conversion of int to Py_ssize_t is harmless in the changed
locations. But this being C code, it should be audited with care.
Differential Revision: https://phab.mercurial-scm.org/D6197
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 04 Apr 2019 15:21:30 -0700 |
parents | b01bbb8ff1f2 |
children | 668eff08387f |
files | mercurial/cext/parsers.c |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cext/parsers.c Thu Apr 04 15:18:06 2019 -0700 +++ b/mercurial/cext/parsers.c Thu Apr 04 15:21:30 2019 -0700 @@ -7,6 +7,7 @@ the GNU General Public License, incorporated herein by reference. */ +#define PY_SSIZE_T_CLEAN #include <Python.h> #include <ctype.h> #include <stddef.h> @@ -164,8 +165,9 @@ PyObject *fname = NULL, *cname = NULL, *entry = NULL; char state, *cur, *str, *cpos; int mode, size, mtime; - unsigned int flen, len, pos = 40; - int readlen; + unsigned int flen, pos = 40; + Py_ssize_t len = 40; + Py_ssize_t readlen; if (!PyArg_ParseTuple( args, PY23("O!O!s#:parse_dirstate", "O!O!y#:parse_dirstate"), @@ -585,8 +587,7 @@ static PyObject *fm1readmarkers(PyObject *self, PyObject *args) { const char *data, *dataend; - int datalen; - Py_ssize_t offset, stop; + Py_ssize_t datalen, offset, stop; PyObject *markers = NULL; if (!PyArg_ParseTuple(args, PY23("s#nn", "y#nn"), &data, &datalen,