From 571b4bc02f9520f6be27fb3a289a11b9264138ef Mon Sep 17 00:00:00 2001
From: Mark Florisson <markflorisson88@gmail.com>
Date: Sun, 11 Nov 2012 14:17:00 +0000
Subject: [PATCH] Use __Pyx_PyIndex_Check instead of PyIndex_Check

---
 Cython/Includes/cpython/number.pxd | 2 +-
 Cython/Utility/MemoryView.pyx      | 2 +-
 Cython/Utility/MemoryView_C.c      | 6 ------
 Cython/Utility/ModuleSetupCode.c   | 5 ++++-
 4 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/Cython/Includes/cpython/number.pxd b/Cython/Includes/cpython/number.pxd
index 6304102ec..c41225d67 100644
--- a/Cython/Includes/cpython/number.pxd
+++ b/Cython/Includes/cpython/number.pxd
@@ -246,6 +246,6 @@ cdef extern from "Python.h":
     # and the value is clipped to PY_SSIZE_T_MIN for a negative
     # integer or PY_SSIZE_T_MAX for a positive integer.
 
-    bint PyIndex_Check(object o)
+    bint PyIndex_Check "__Pyx_PyIndex_Check" (object)
     # Returns True if o is an index integer (has the nb_index slot of
     # the tp_as_number structure filled in).
diff --git a/Cython/Utility/MemoryView.pyx b/Cython/Utility/MemoryView.pyx
index 250fcff3e..d98933bab 100644
--- a/Cython/Utility/MemoryView.pyx
+++ b/Cython/Utility/MemoryView.pyx
@@ -6,7 +6,7 @@ import cython
 
 # from cpython cimport ...
 cdef extern from "Python.h":
-    int PyIndex_Check(object)
+    int PyIndex_Check "__Pyx_PyIndex_Check" (object)
     object PyLong_FromVoidPtr(void *)
 
 cdef extern from "pythread.h":
diff --git a/Cython/Utility/MemoryView_C.c b/Cython/Utility/MemoryView_C.c
index 66329a44a..942c9b647 100644
--- a/Cython/Utility/MemoryView_C.c
+++ b/Cython/Utility/MemoryView_C.c
@@ -115,12 +115,6 @@ static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(__pyx_atomic_int *ac
 #define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
 static CYTHON_INLINE void __Pyx_INC_MEMVIEW({{memviewslice_name}} *, int, int);
 static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW({{memviewslice_name}} *, int, int);
-
-#if PY_VERSION_HEX < 0x02050000
-    /* NumPy headers define PyIndex_Check incorrectly */
-    #undef PyIndex_Check
-    #define PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && !PyComplex_Check(o))
-#endif
 /////////////// MemviewSliceIndex.proto ///////////////
 static CYTHON_INLINE char *__pyx_memviewslice_index_full(const char *bufp, Py_ssize_t idx, Py_ssize_t stride, Py_ssize_t suboffset);
 
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c
index f01725caf..fcb096d47 100644
--- a/Cython/Utility/ModuleSetupCode.c
+++ b/Cython/Utility/ModuleSetupCode.c
@@ -52,12 +52,15 @@
                                 (PyErr_Format(PyExc_TypeError, \
                                               "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
                                  (PyObject*)0))
-  #define PyIndex_Check(o)     (PyNumber_Check(o) && !PyFloat_Check(o) && !PyComplex_Check(o))
+  #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
+                                  !PyComplex_Check(o))
+  #define PyIndex_Check __Pyx_PyIndex_Check
   #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
   #define __PYX_BUILD_PY_SSIZE_T "i"
 #else
   #define __PYX_BUILD_PY_SSIZE_T "n"
   #define CYTHON_FORMAT_SSIZE_T "z"
+  #define __Pyx_PyIndex_Check PyIndex_Check
 #endif
 
 #if PY_VERSION_HEX < 0x02060000
-- 
2.30.9