[PATCH stable] cext: back out ec3c06a1c554 (use modern buffer protocol in mpatch_flist())
Gregory Szorc
gregory.szorc at gmail.com
Thu May 14 19:15:37 UTC 2020
On Wed, May 13, 2020 at 5:15 PM Manuel Jacob <me at manueljacob.de> wrote:
> # HG changeset patch
> # User Manuel Jacob <me at manueljacob.de>
> # Date 1589415041 -7200
> # Thu May 14 02:10:41 2020 +0200
> # Branch stable
> # Node ID fdbe20620a267f2cc8fb01b60a293117f00cebdb
> # Parent cf3e07d7648a4371ce584d15dd692e7a6845792f
> cext: back out ec3c06a1c554 (use modern buffer protocol in mpatch_flist())
>
I'm -0 on committing this because nobody should be running Python <2.7.4 in
2020. Although apparently you are. May I ask how you managed to discover
this? (The original patch landed in October 2018 and as far as I know
nobody has reported an issue until now.)
>
> On old Python versions (prior to 2.7.4), old-style 'buffer' objects were
> not
> recognized by the new-style buffer API. See
> https://bugs.python.org/issue10211
> for details.
>
> Since old-style buffers are deprecated on Python 3 and the Python version
> that
> fixes this issue was released over 7 years ago, I'm not actually proposing
> that this patch should be committed. It might still be helpful for people
> compiling Mercurial on very old versions of Python.
>
> diff --git a/mercurial/cext/mpatch.c b/mercurial/cext/mpatch.c
> --- a/mercurial/cext/mpatch.c
> +++ b/mercurial/cext/mpatch.c
> @@ -50,25 +50,24 @@
>
> struct mpatch_flist *cpygetitem(void *bins, ssize_t pos)
> {
> - Py_buffer buffer;
> - struct mpatch_flist *res = NULL;
> + const char *buffer;
> + struct mpatch_flist *res;
> + ssize_t blen;
> int r;
>
> PyObject *tmp = PyList_GetItem((PyObject *)bins, pos);
> if (!tmp) {
> return NULL;
> }
> - if (PyObject_GetBuffer(tmp, &buffer, PyBUF_CONTIG_RO)) {
> + if (PyObject_AsCharBuffer(tmp, &buffer, (Py_ssize_t *)&blen)) {
> return NULL;
> }
> - if ((r = mpatch_decode(buffer.buf, buffer.len, &res)) < 0) {
> + if ((r = mpatch_decode(buffer, blen, &res)) < 0) {
> if (!PyErr_Occurred()) {
> setpyerr(r);
> }
> - res = NULL;
> + return NULL;
> }
> -
> - PyBuffer_Release(&buffer);
> return res;
> }
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20200514/f857d35b/attachment-0002.html>
More information about the Mercurial-devel
mailing list