This is needed to avoid a deprecation warning on Python 3.8.
With this change, we no longer see deprecation warnings for
this issue on Python 3.8.
pulkit |
hg-reviewers |
This is needed to avoid a deprecation warning on Python 3.8.
With this change, we no longer see deprecation warnings for
this issue on Python 3.8.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/cext/osutil.c (6 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Gregory Szorc | Apr 4 2019, 6:24 PM |
/* | /* | ||||
osutil.c - native operating system services | osutil.c - native operating system services | ||||
Copyright 2007 Matt Mackall and others | Copyright 2007 Matt Mackall and others | ||||
This software may be used and distributed according to the terms of | This software may be used and distributed according to the terms of | ||||
the GNU General Public License, incorporated herein by reference. | the GNU General Public License, incorporated herein by reference. | ||||
*/ | */ | ||||
#define _ATFILE_SOURCE | #define _ATFILE_SOURCE | ||||
#define PY_SSIZE_T_CLEAN | |||||
#include <Python.h> | #include <Python.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#ifdef _WIN32 | #ifdef _WIN32 | ||||
stp->st_ctime = to_python_time(&fd->ftCreationTime); | stp->st_ctime = to_python_time(&fd->ftCreationTime); | ||||
if (kind == _S_IFREG) | if (kind == _S_IFREG) | ||||
stp->st_size = ((__int64)fd->nFileSizeHigh << 32) | stp->st_size = ((__int64)fd->nFileSizeHigh << 32) | ||||
+ fd->nFileSizeLow; | + fd->nFileSizeLow; | ||||
return Py_BuildValue(PY23("siN", "yiN"), fd->cFileName, | return Py_BuildValue(PY23("siN", "yiN"), fd->cFileName, | ||||
kind, py_st); | kind, py_st); | ||||
} | } | ||||
static PyObject *_listdir(char *path, int plen, int wantstat, char *skip) | static PyObject *_listdir(char *path, Py_ssize_t plen, int wantstat, char *skip) | ||||
{ | { | ||||
PyObject *rval = NULL; /* initialize - return value */ | PyObject *rval = NULL; /* initialize - return value */ | ||||
PyObject *list; | PyObject *list; | ||||
HANDLE fh; | HANDLE fh; | ||||
WIN32_FIND_DATAA fd; | WIN32_FIND_DATAA fd; | ||||
char *pattern; | char *pattern; | ||||
/* build the path + \* pattern string */ | /* build the path + \* pattern string */ | ||||
#endif /* ndef _WIN32 */ | #endif /* ndef _WIN32 */ | ||||
static PyObject *listdir(PyObject *self, PyObject *args, PyObject *kwargs) | static PyObject *listdir(PyObject *self, PyObject *args, PyObject *kwargs) | ||||
{ | { | ||||
PyObject *statobj = NULL; /* initialize - optional arg */ | PyObject *statobj = NULL; /* initialize - optional arg */ | ||||
PyObject *skipobj = NULL; /* initialize - optional arg */ | PyObject *skipobj = NULL; /* initialize - optional arg */ | ||||
char *path, *skip = NULL; | char *path, *skip = NULL; | ||||
int wantstat, plen; | Py_ssize_t plen; | ||||
int wantstat; | |||||
static char *kwlist[] = {"path", "stat", "skip", NULL}; | static char *kwlist[] = {"path", "stat", "skip", NULL}; | ||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, PY23("s#|OO:listdir", | if (!PyArg_ParseTupleAndKeywords(args, kwargs, PY23("s#|OO:listdir", | ||||
"y#|OO:listdir"), | "y#|OO:listdir"), | ||||
kwlist, &path, &plen, &statobj, &skipobj)) | kwlist, &path, &plen, &statobj, &skipobj)) | ||||
return NULL; | return NULL; | ||||