comparison mercurial/cext/parsers.c @ 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 763b45bc4483
children 509a0477b3a6
comparison
equal deleted inserted replaced
42067:b01bbb8ff1f2 42068:896b19d12c08
5 5
6 This software may be used and distributed according to the terms of 6 This software may be used and distributed according to the terms of
7 the GNU General Public License, incorporated herein by reference. 7 the GNU General Public License, incorporated herein by reference.
8 */ 8 */
9 9
10 #define PY_SSIZE_T_CLEAN
10 #include <Python.h> 11 #include <Python.h>
11 #include <ctype.h> 12 #include <ctype.h>
12 #include <stddef.h> 13 #include <stddef.h>
13 #include <string.h> 14 #include <string.h>
14 15
162 { 163 {
163 PyObject *dmap, *cmap, *parents = NULL, *ret = NULL; 164 PyObject *dmap, *cmap, *parents = NULL, *ret = NULL;
164 PyObject *fname = NULL, *cname = NULL, *entry = NULL; 165 PyObject *fname = NULL, *cname = NULL, *entry = NULL;
165 char state, *cur, *str, *cpos; 166 char state, *cur, *str, *cpos;
166 int mode, size, mtime; 167 int mode, size, mtime;
167 unsigned int flen, len, pos = 40; 168 unsigned int flen, pos = 40;
168 int readlen; 169 Py_ssize_t len = 40;
170 Py_ssize_t readlen;
169 171
170 if (!PyArg_ParseTuple( 172 if (!PyArg_ParseTuple(
171 args, PY23("O!O!s#:parse_dirstate", "O!O!y#:parse_dirstate"), 173 args, PY23("O!O!s#:parse_dirstate", "O!O!y#:parse_dirstate"),
172 &PyDict_Type, &dmap, &PyDict_Type, &cmap, &str, &readlen)) { 174 &PyDict_Type, &dmap, &PyDict_Type, &cmap, &str, &readlen)) {
173 goto quit; 175 goto quit;
583 } 585 }
584 586
585 static PyObject *fm1readmarkers(PyObject *self, PyObject *args) 587 static PyObject *fm1readmarkers(PyObject *self, PyObject *args)
586 { 588 {
587 const char *data, *dataend; 589 const char *data, *dataend;
588 int datalen; 590 Py_ssize_t datalen, offset, stop;
589 Py_ssize_t offset, stop;
590 PyObject *markers = NULL; 591 PyObject *markers = NULL;
591 592
592 if (!PyArg_ParseTuple(args, PY23("s#nn", "y#nn"), &data, &datalen, 593 if (!PyArg_ParseTuple(args, PY23("s#nn", "y#nn"), &data, &datalen,
593 &offset, &stop)) { 594 &offset, &stop)) {
594 return NULL; 595 return NULL;