Mercurial > public > mercurial-scm > hg
diff mercurial/cext/osutil.c @ 48821:b0dd39b91e7a
cext: remove PY23()
Since we always run on Python 3 now, we no longer need this
macro to support Python 2. We refactor all users to just use
the 2nd argument.
Differential Revision: https://phab.mercurial-scm.org/D12232
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 20 Feb 2022 16:09:02 -0700 |
parents | e9ca736f5b52 |
children | 3aa1b7ded52c |
line wrap: on
line diff
--- a/mercurial/cext/osutil.c Sun Feb 20 16:13:57 2022 -0700 +++ b/mercurial/cext/osutil.c Sun Feb 20 16:09:02 2022 -0700 @@ -198,7 +198,7 @@ ? _S_IFDIR : _S_IFREG; if (!wantstat) - return Py_BuildValue(PY23("si", "yi"), fd->cFileName, kind); + return Py_BuildValue("yi", fd->cFileName, kind); py_st = PyObject_CallObject((PyObject *)&listdir_stat_type, NULL); if (!py_st) @@ -216,7 +216,7 @@ if (kind == _S_IFREG) stp->st_size = ((__int64)fd->nFileSizeHigh << 32) + fd->nFileSizeLow; - return Py_BuildValue(PY23("siN", "yiN"), fd->cFileName, + return Py_BuildValue("yiN", fd->cFileName, kind, py_st); } @@ -404,10 +404,10 @@ PyObject *stat = makestat(&st); if (!stat) goto error; - elem = Py_BuildValue(PY23("siN", "yiN"), ent->d_name, + elem = Py_BuildValue("yiN", ent->d_name, kind, stat); } else - elem = Py_BuildValue(PY23("si", "yi"), ent->d_name, + elem = Py_BuildValue("yi", ent->d_name, kind); if (!elem) goto error; @@ -585,10 +585,10 @@ stat = makestat(&st); if (!stat) goto error; - elem = Py_BuildValue(PY23("siN", "yiN"), + elem = Py_BuildValue("yiN", filename, kind, stat); } else - elem = Py_BuildValue(PY23("si", "yi"), + elem = Py_BuildValue("yi", filename, kind); if (!elem) goto error; @@ -772,7 +772,7 @@ static PyObject *setprocname(PyObject *self, PyObject *args) { const char *name = NULL; - if (!PyArg_ParseTuple(args, PY23("s", "y"), &name)) + if (!PyArg_ParseTuple(args, "y", &name)) return NULL; #if defined(SETPROCNAME_USE_SETPROCTITLE) @@ -1127,14 +1127,14 @@ const char *path = NULL; struct statfs buf; int r; - if (!PyArg_ParseTuple(args, PY23("s", "y"), &path)) + if (!PyArg_ParseTuple(args, "y", &path)) return NULL; memset(&buf, 0, sizeof(buf)); r = statfs(path, &buf); if (r != 0) return PyErr_SetFromErrno(PyExc_OSError); - return Py_BuildValue(PY23("s", "y"), describefstype(&buf)); + return Py_BuildValue("y", describefstype(&buf)); } #endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */ @@ -1145,14 +1145,14 @@ const char *path = NULL; struct statfs buf; int r; - if (!PyArg_ParseTuple(args, PY23("s", "y"), &path)) + if (!PyArg_ParseTuple(args, "y", &path)) return NULL; memset(&buf, 0, sizeof(buf)); r = statfs(path, &buf); if (r != 0) return PyErr_SetFromErrno(PyExc_OSError); - return Py_BuildValue(PY23("s", "y"), buf.f_mntonname); + return Py_BuildValue("y", buf.f_mntonname); } #endif /* defined(HAVE_BSD_STATFS) */ @@ -1187,8 +1187,7 @@ static char *kwlist[] = {"path", "stat", "skip", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, PY23("s#|OO:listdir", - "y#|OO:listdir"), + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y#|OO:listdir", kwlist, &path, &plen, &statobj, &skipobj)) return NULL; @@ -1221,8 +1220,7 @@ int plus; FILE *fp; - if (!PyArg_ParseTupleAndKeywords(args, kwds, PY23("et|si:posixfile", - "et|yi:posixfile"), + if (!PyArg_ParseTupleAndKeywords(args, kwds, "et|yi:posixfile", kwlist, Py_FileSystemDefaultEncoding, &name, &mode, &bufsize))