[PATCH 7 of 7] parsers: use PyVarObject_HEAD_INIT

Augie Fackler raf at durin42.com
Sun Oct 9 04:51:21 EDT 2016


On Sat, Oct 08, 2016 at 10:48:13PM +0200, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1475959442 -7200
> #      Sat Oct 08 22:44:02 2016 +0200
> # Node ID ad527a4c62ad35b84c4ad25d080ee427528966fa
> # Parent  40775aad0c78f6c1fd07e7160d50426efbe032ed
> parsers: use PyVarObject_HEAD_INIT

Queued these with enthusiasm!

>
> The macro changed slightly in Python 3, introducing curly brackets
> that somehow confuse Clang into issuing a ton of compiler warnings.
> Using PyVarObject_HEAD_INIT makes these go away.
>
> It's worth noting that the code is identical: the 2nd argument to
> PyVarObject_HEAD_INIT is assigned to the ob_size field and is
> inserted immediately after "PyObject_HEAD_INIT(type)" is generated.
> Compilers are weird.
>
> diff --git a/mercurial/parsers.c b/mercurial/parsers.c
> --- a/mercurial/parsers.c
> +++ b/mercurial/parsers.c
> @@ -2515,10 +2515,9 @@ static PyGetSetDef index_getset[] = {
>       {NULL} /* Sentinel */
>  };
>
>  static PyTypeObject indexType = {
> -	PyObject_HEAD_INIT(NULL)
> -	0,                         /* ob_size */
> +	PyVarObject_HEAD_INIT(NULL, 0)
>       "parsers.index",           /* tp_name */
>       sizeof(indexObject),       /* tp_basicsize */
>       0,                         /* tp_itemsize */
>       (destructor)index_dealloc, /* tp_dealloc */
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list