Patchwork [5,of,6] parsers: avoid PySliceObject cast on Python 3

login
register
mail settings
Submitter Gregory Szorc
Date Oct. 13, 2016, 7:44 p.m.
Message ID <8501cbf27b0ae7402f6c.1476387857@gps-mbp.local>
Download mbox | patch
Permalink /patch/17063/
State Accepted
Headers show

Comments

Gregory Szorc - Oct. 13, 2016, 7:44 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1476358493 -7200
#      Thu Oct 13 13:34:53 2016 +0200
# Node ID 8501cbf27b0ae7402f6c6df6cea68b757a939bb9
# Parent  569eb5b02fff32b0517c4c1d5ef8fb82dab33023
parsers: avoid PySliceObject cast on Python 3

PySlice_GetIndicesEx() accepts a PySliceObject* on Python 2 and a
PyObject* on Python 3. Casting to PySliceObject* on Python 3 was
yielding a compiler warning. So stop doing that.

With this patch, I no longer see any compiler warnings when
building the core extensions for Python 3!

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -2275,9 +2275,14 @@  static int index_slice_del(indexObject *
 	Py_ssize_t start, stop, step, slicelength;
 	Py_ssize_t length = index_length(self);
 	int ret = 0;
 
+/* Argument changed from PySliceObject* to PyObject* in Python 3. */
+#ifdef IS_PY3K
+	if (PySlice_GetIndicesEx(item, length,
+#else
 	if (PySlice_GetIndicesEx((PySliceObject*)item, length,
+#endif
 				 &start, &stop, &step, &slicelength) < 0)
 		return -1;
 
 	if (slicelength <= 0)