From patchwork Sat Oct 8 20:48:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7,of,7] parsers: use PyVarObject_HEAD_INIT From: Gregory Szorc X-Patchwork-Id: 16966 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sat, 08 Oct 2016 22:48:13 +0200 # HG changeset patch # User Gregory Szorc # Date 1475959442 -7200 # Sat Oct 08 22:44:02 2016 +0200 # Node ID ad527a4c62ad35b84c4ad25d080ee427528966fa # Parent 40775aad0c78f6c1fd07e7160d50426efbe032ed parsers: use PyVarObject_HEAD_INIT 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 */