On Sat, 08 Oct 2016 22:48:12 +0200, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.sz...@gmail.com>
> # Date 1475958082 -7200
> #      Sat Oct 08 22:21:22 2016 +0200
> # Node ID 40775aad0c78f6c1fd07e7160d50426efbe032ed
> # Parent  a33e93c20bc1290af106a0f077fece735ea05245
> pathencode: use Py_SIZE directly

> @@ -637,9 +638,10 @@ static PyObject *hashmangle(const char *
>       if (lastdot >= 0)
>               memcopy(dest, &destlen, destsize, &src[lastdot],
>                       len - lastdot - 1);
>  
> -     PyBytes_GET_SIZE(ret) = destlen;
> +     PyBytes_Check(ret);
> +     Py_SIZE(ret) = destlen;
>  
>       return ret;
>  }
>  
> @@ -749,9 +751,10 @@ PyObject *pathencode(PyObject *self, PyO
>  
>               newobj = PyBytes_FromStringAndSize(NULL, newlen);
>  
>               if (newobj) {
> -                     PyBytes_GET_SIZE(newobj)--;
> +                     PyBytes_Check(newobj);
> +                     Py_SIZE(newobj)--;

Maybe we need to wrap these PyBytes_Check()s by assert() ?
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to