Mercurial > public > mercurial-scm > hg
diff mercurial/cext/osutil.c @ 36619:1f8c3fadbb8e
py3: bulk-replace bytes format specifier passed to Py_BuildValue()
On Python 3, "s" means a utf-8 string. We have to use "y" for bytes, sigh.
https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue
Substituted using the following pattern with some manual fixes:
'\b(Py_BuildValue)\((\s*)"([^"]+)"'
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 03 Mar 2018 06:08:22 -0500 |
parents | e01549a7bf0a |
children | 186c6df3a373 |
line wrap: on
line diff
--- a/mercurial/cext/osutil.c Sat Mar 03 05:58:41 2018 -0500 +++ b/mercurial/cext/osutil.c Sat Mar 03 06:08:22 2018 -0500 @@ -184,7 +184,7 @@ ? _S_IFDIR : _S_IFREG; if (!wantstat) - return Py_BuildValue("si", fd->cFileName, kind); + return Py_BuildValue(PY23("si", "yi"), fd->cFileName, kind); py_st = PyObject_CallObject((PyObject *)&listdir_stat_type, NULL); if (!py_st) @@ -202,7 +202,7 @@ if (kind == _S_IFREG) stp->st_size = ((__int64)fd->nFileSizeHigh << 32) + fd->nFileSizeLow; - return Py_BuildValue("siN", fd->cFileName, + return Py_BuildValue(PY23("siN", "yiN"), fd->cFileName, kind, py_st); } @@ -390,9 +390,11 @@ stat = makestat(&st); if (!stat) goto error; - elem = Py_BuildValue("siN", ent->d_name, kind, stat); + elem = Py_BuildValue(PY23("siN", "yiN"), ent->d_name, + kind, stat); } else - elem = Py_BuildValue("si", ent->d_name, kind); + elem = Py_BuildValue(PY23("si", "yi"), ent->d_name, + kind); if (!elem) goto error; stat = NULL; @@ -570,9 +572,11 @@ stat = makestat(&st); if (!stat) goto error; - elem = Py_BuildValue("siN", filename, kind, stat); + elem = Py_BuildValue(PY23("siN", "yiN"), + filename, kind, stat); } else - elem = Py_BuildValue("si", filename, kind); + elem = Py_BuildValue(PY23("si", "yi"), + filename, kind); if (!elem) goto error; stat = NULL; @@ -1108,7 +1112,7 @@ r = statfs(path, &buf); if (r != 0) return PyErr_SetFromErrno(PyExc_OSError); - return Py_BuildValue("s", describefstype(&buf)); + return Py_BuildValue(PY23("s", "y"), describefstype(&buf)); } #endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */ @@ -1126,7 +1130,7 @@ r = statfs(path, &buf); if (r != 0) return PyErr_SetFromErrno(PyExc_OSError); - return Py_BuildValue("s", buf.f_mntonname); + return Py_BuildValue(PY23("s", "y"), buf.f_mntonname); } #endif /* defined(HAVE_BSD_STATFS) */