D4841: cext: use modern buffer protocol in mpatch_flist()
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Wed Oct 3 08:29:30 EDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGec3c06a1c554: cext: use modern buffer protocol in mpatch_flist() (authored by indygreg, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D4841?vs=11575&id=11598
REVISION DETAIL
https://phab.mercurial-scm.org/D4841
AFFECTED FILES
mercurial/cext/mpatch.c
CHANGE DETAILS
diff --git a/mercurial/cext/mpatch.c b/mercurial/cext/mpatch.c
--- a/mercurial/cext/mpatch.c
+++ b/mercurial/cext/mpatch.c
@@ -50,21 +50,22 @@
struct mpatch_flist *cpygetitem(void *bins, ssize_t pos)
{
- const char *buffer;
- struct mpatch_flist *res;
- ssize_t blen;
+ Py_buffer buffer;
+ struct mpatch_flist *res = NULL;
int r;
PyObject *tmp = PyList_GetItem((PyObject *)bins, pos);
if (!tmp)
return NULL;
- if (PyObject_AsCharBuffer(tmp, &buffer, (Py_ssize_t *)&blen))
+ if (PyObject_GetBuffer(tmp, &buffer, PyBUF_CONTIG_RO))
return NULL;
- if ((r = mpatch_decode(buffer, blen, &res)) < 0) {
+ if ((r = mpatch_decode(buffer.buf, buffer.len, &res)) < 0) {
if (!PyErr_Occurred())
setpyerr(r);
- return NULL;
+ res = NULL;
}
+
+ PyBuffer_Release(&buffer);
return res;
}
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list