Skip to content

Loading…

BUG: don't pollute public namespace with customized PyIndex_Check on Py2.4 #307

Closed
wants to merge 2 commits into from

4 participants

@pv
NumPy member
pv commented

Move compatibility #define for PyIndex_Check on Python 2.4 to a private compat header

The problem is that including the public Numpy header "arrayobject.h" defines a compatibility wrapper for "PyIndex_Check" on Python 2.4. Moreover, this compatibility wrapper functions incorrectly... This #define probably should not be in the public namespace, as it already causes problems with Cython on Py2.4 (which we hit into in Scipy release):
http://permalink.gmane.org/gmane.comp.python.cython.devel/13983

The second commit moves all non Py3-stuff out of npy_3compat.h to another, more private compat header, for stylistic reasons (mainly because #defining PyIndex_Check to 0 rather than something like PyNumber_Check is possibly not the correct solution, but I didn't want to go changing it inside Numpy for this).

A question with this PR is --- is there 3rd party software out there that relies on Numpy headers defining the otherwise missing PyIndex_Check being defined, and do we care. I'd say we don't care, this seems like a corner case, and the current behavior in Numpy is wrong.

pv added some commits
@pv pv BUG: core: don't pollute public namespace with PyIndex_Check on Pytho…
…n 2.4

Public numpy headers shouldn't define a replacement PyIndex_Check.  This
causes unexpected behavior in Python2.4 in 3rd party code.
1f8f966
@pv pv STY: core: move non-Py3 specific stuff out from npy_3kcompat.h to pri…
…vate npy_pycompat.h

npy_3kcompat.h is semi-private, so this can be done.
d3e299c
@charris
NumPy member

Looks good to me. Should we also move python version dependent things like the DEPRECATE macro?

@pv
NumPy member
pv commented

If they're not part of the public API, why not. I guess DEPRECATE is not, at least Scipy doesn't use it.

@teoliphant
NumPy member

It might be time to deprecate Python 2.4 support as well. The thinking behind the PyIndex_Check being set to 0 is that before 2.4 there is no Index attribute and so no object can be an "index" object. This is the correct behavior. It is Cython that is doing the wrong thing here.

In practice, it depends on why people are using PyIndex_Check in the code. An index is anything that can be interpreted as an integer. A number is quite a bit more general than that. Code might be trying to access the tp_index slot in the number structure after doing a PyIndex_Check. You have to return 0 if there is no such slot (like in Python 2.4).

Cython code should not be using PyIndex_Check as it if were the same thing as PyNumber_Check. That is a mistake. But, I'm not going to try and fix that problem, as they must not be accessing the tp_index slot directly.

It's fine to make our version private, though --- especially because it's just a Python 2.4 thing.

@pv
NumPy member
pv commented

As far as I see, Cython is using PyIndex_Check only to check if object can be used for indexing, and in that case functional backward compatibility is easiest to achieve via PyNumber_Check && !PyFloat_Check && !PyComplex_Check. Trying to access the tp_index slot on Python2.4 causes a compile error, I think.

EDIT: uhh, or maybe the "correct" compatibility mode should be PyInt_Check on Py2.4. I'm not sure what Cython should do here...

@charris charris commented on the diff
numpy/core/src/private/npy_pycompat.h
@@ -0,0 +1,24 @@
+#ifndef _NPY_PYCOMPAT_H_
+#define _NPY_PYCOMPAT_H_
+
+#include "numpy/npy_3kcompat.h"
+
+/*
+ * Accessing items of ob_base
+ */
+
+#if (PY_VERSION_HEX < 0x02060000)
@charris NumPy member
charris added a note

Aren't these needed for Scipy?

@pv NumPy member
pv added a note

None of them is used in Scipy --- apart from Cython/Swig generated files which have their own versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@charris
NumPy member

OK. The new stuff in #354 should probably go into the new file.

@njsmith
NumPy member

Github says this has a merge conflict, but other than that, it sounds ready to go?

@charris
NumPy member

A rebase should fix the conflict, then I think we can put it in.

@charris
NumPy member

Let's do 354 first, then fix this one to move the new functions into npy_compat. Sound good?

@charris
NumPy member

OK, I merged 354, so this needs a fixup.

@charris
NumPy member

Fixed up in PR 355.

@charris
NumPy member

Rebased version committed.

@charris charris closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 11, 2012
  1. @pv

    BUG: core: don't pollute public namespace with PyIndex_Check on Pytho…

    pv committed
    …n 2.4
    
    Public numpy headers shouldn't define a replacement PyIndex_Check.  This
    causes unexpected behavior in Python2.4 in 3rd party code.
  2. @pv

    STY: core: move non-Py3 specific stuff out from npy_3kcompat.h to pri…

    pv committed
    …vate npy_pycompat.h
    
    npy_3kcompat.h is semi-private, so this can be done.
Showing with 80 additions and 65 deletions.
  1. +0 −11 numpy/core/include/numpy/npy_3kcompat.h
  2. +0 −2 numpy/core/include/numpy/npy_common.h
  3. +1 −1 numpy/core/src/dummymodule.c
  4. +1 −1 numpy/core/src/multiarray/array_assign.c
  5. +1 −1 numpy/core/src/multiarray/array_assign_array.c
  6. +1 −1 numpy/core/src/multiarray/array_assign_scalar.c
  7. +1 −1 numpy/core/src/multiarray/arrayobject.c
  8. +1 −1 numpy/core/src/multiarray/arraytypes.c.src
  9. +1 −1 numpy/core/src/multiarray/boolean_ops.c.src
  10. +1 −1 numpy/core/src/multiarray/buffer.c
  11. +1 −1 numpy/core/src/multiarray/calculation.c
  12. +1 −1 numpy/core/src/multiarray/common.c
  13. +1 −1 numpy/core/src/multiarray/conversion_utils.c
  14. +1 −1 numpy/core/src/multiarray/convert.c
  15. +1 −1 numpy/core/src/multiarray/convert_datatype.c
  16. +1 −1 numpy/core/src/multiarray/ctors.c
  17. +1 −1 numpy/core/src/multiarray/datetime.c
  18. +1 −1 numpy/core/src/multiarray/datetime_busday.c
  19. +1 −1 numpy/core/src/multiarray/datetime_busdaycal.c
  20. +1 −1 numpy/core/src/multiarray/datetime_strings.c
  21. +1 −1 numpy/core/src/multiarray/descriptor.c
  22. +1 −1 numpy/core/src/multiarray/dtype_transfer.c
  23. +1 −1 numpy/core/src/multiarray/einsum.c.src
  24. +1 −1 numpy/core/src/multiarray/flagsobject.c
  25. +1 −1 numpy/core/src/multiarray/getset.c
  26. +1 −1 numpy/core/src/multiarray/hashdescr.c
  27. +1 −1 numpy/core/src/multiarray/item_selection.c
  28. +1 −1 numpy/core/src/multiarray/iterators.c
  29. +1 −1 numpy/core/src/multiarray/mapping.c
  30. +1 −1 numpy/core/src/multiarray/methods.c
  31. +1 −1 numpy/core/src/multiarray/multiarray_tests.c.src
  32. +1 −1 numpy/core/src/multiarray/multiarraymodule.c
  33. +1 −1 numpy/core/src/multiarray/na_mask.c
  34. +1 −1 numpy/core/src/multiarray/na_object.c
  35. +1 −1 numpy/core/src/multiarray/nditer_impl.h
  36. +2 −2 numpy/core/src/multiarray/nditer_pywrap.c
  37. +1 −1 numpy/core/src/multiarray/number.c
  38. +1 −1 numpy/core/src/multiarray/numpymemoryview.c
  39. +1 −1 numpy/core/src/multiarray/numpyos.c
  40. +1 −1 numpy/core/src/multiarray/reduction.c
  41. +1 −1 numpy/core/src/multiarray/refcount.c
  42. +1 −1 numpy/core/src/multiarray/scalarapi.c
  43. +1 −1 numpy/core/src/multiarray/scalartypes.c.src
  44. +1 −1 numpy/core/src/multiarray/sequence.c
  45. +1 −1 numpy/core/src/multiarray/shape.c
  46. +1 −1 numpy/core/src/multiarray/ucsnarrow.c
  47. +1 −1 numpy/core/src/multiarray/usertypes.c
  48. +24 −0 numpy/core/src/private/npy_pycompat.h
  49. +1 −1 numpy/core/src/scalarmathmodule.c.src
  50. +1 −1 numpy/core/src/umath/funcs.inc.src
  51. +1 −1 numpy/core/src/umath/loops.c.src
  52. +1 −1 numpy/core/src/umath/ufunc_object.c
  53. +1 −1 numpy/core/src/umath/ufunc_type_resolution.c
  54. +1 −1 numpy/core/src/umath/umath_tests.c.src
  55. +4 −0 numpy/lib/src/_compiled_base.c
View
11 numpy/core/include/numpy/npy_3kcompat.h
@@ -137,17 +137,6 @@ PyUnicode_Concat2(PyObject **left, PyObject *right)
*left = newobj;
}
-
-/*
- * Accessing items of ob_base
- */
-
-#if (PY_VERSION_HEX < 0x02060000)
-#define Py_TYPE(o) (((PyObject*)(o))->ob_type)
-#define Py_REFCNT(o) (((PyObject*)(o))->ob_refcnt)
-#define Py_SIZE(o) (((PyVarObject*)(o))->ob_size)
-#endif
-
/*
* PyFile_* compatibility
*/
View
2 numpy/core/include/numpy/npy_common.h
@@ -48,9 +48,7 @@ typedef Py_uintptr_t npy_uintp;
#define PY_SSIZE_T_MIN INT_MIN
#endif
#define NPY_SSIZE_T_PYFMT "i"
-#undef PyIndex_Check
#define constchar const char
-#define PyIndex_Check(op) 0
#else
#define NPY_SSIZE_T_PYFMT "n"
#define constchar char
View
2 numpy/core/src/dummymodule.c
@@ -9,7 +9,7 @@
#define NPY_NO_DEPRECATED_API NPY_API_VERSION
#include <Python.h>
-#include <numpy/npy_3kcompat.h>
+#include <npy_pycompat.h>
static struct PyMethodDef methods[] = {
{NULL, NULL, 0, NULL}
View
2 numpy/core/src/multiarray/array_assign.c
@@ -16,7 +16,7 @@
#include <numpy/ndarraytypes.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "shape.h"
View
2 numpy/core/src/multiarray/array_assign_array.c
@@ -15,7 +15,7 @@
#include <numpy/ndarraytypes.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "convert_datatype.h"
#include "methods.h"
View
2 numpy/core/src/multiarray/array_assign_scalar.c
@@ -15,7 +15,7 @@
#include <numpy/ndarraytypes.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "convert_datatype.h"
#include "methods.h"
View
2 numpy/core/src/multiarray/arrayobject.c
@@ -32,7 +32,7 @@ maintainer email: oliphant.travis@ieee.org
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "common.h"
View
2 numpy/core/src/multiarray/arraytypes.c.src
@@ -7,7 +7,7 @@
#define _MULTIARRAYMODULE
#include "numpy/arrayobject.h"
#include "numpy/arrayscalars.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "numpy/npy_math.h"
#include "numpy/halffloat.h"
View
2 numpy/core/src/multiarray/boolean_ops.c.src
@@ -22,7 +22,7 @@
#include <numpy/arrayobject.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "reduction.h"
View
2 numpy/core/src/multiarray/buffer.c
@@ -9,7 +9,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "buffer.h"
#include "numpyos.h"
View
2 numpy/core/src/multiarray/calculation.c
@@ -8,7 +8,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "common.h"
#include "number.h"
View
2 numpy/core/src/multiarray/common.c
@@ -6,7 +6,7 @@
#include "numpy/arrayobject.h"
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "usertypes.h"
View
2 numpy/core/src/multiarray/conversion_utils.c
@@ -9,7 +9,7 @@
#include "numpy/arrayobject.h"
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "common.h"
#include "arraytypes.h"
View
2 numpy/core/src/multiarray/convert.c
@@ -9,7 +9,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "arrayobject.h"
#include "mapping.h"
View
2 numpy/core/src/multiarray/convert_datatype.c
@@ -9,7 +9,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "common.h"
#include "scalartypes.h"
View
2 numpy/core/src/multiarray/ctors.c
@@ -11,7 +11,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "common.h"
#include "ctors.h"
View
2 numpy/core/src/multiarray/datetime.c
@@ -18,7 +18,7 @@
#include <numpy/arrayobject.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "numpy/arrayscalars.h"
#include "methods.h"
View
2 numpy/core/src/multiarray/datetime_busday.c
@@ -15,7 +15,7 @@
#include <numpy/arrayobject.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "numpy/arrayscalars.h"
#include "lowlevel_strided_loops.h"
View
2 numpy/core/src/multiarray/datetime_busdaycal.c
@@ -16,7 +16,7 @@
#include <numpy/arrayobject.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "numpy/arrayscalars.h"
#include "lowlevel_strided_loops.h"
View
2 numpy/core/src/multiarray/datetime_strings.c
@@ -17,7 +17,7 @@
#include <numpy/arrayobject.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "numpy/arrayscalars.h"
#include "methods.h"
View
2 numpy/core/src/multiarray/descriptor.c
@@ -11,7 +11,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "_datetime.h"
#include "common.h"
View
2 numpy/core/src/multiarray/dtype_transfer.c
@@ -19,7 +19,7 @@
#include <numpy/arrayobject.h>
#include <numpy/npy_cpu.h>
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "convert_datatype.h"
#include "_datetime.h"
View
2 numpy/core/src/multiarray/einsum.c.src
@@ -16,7 +16,7 @@
#define _MULTIARRAYMODULE
#include <numpy/arrayobject.h>
#include <numpy/halffloat.h>
-#include <numpy/npy_3kcompat.h>
+#include <npy_pycompat.h>
#include <ctype.h>
View
2 numpy/core/src/multiarray/flagsobject.c
@@ -11,7 +11,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "common.h"
View
2 numpy/core/src/multiarray/getset.c
@@ -10,7 +10,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "common.h"
#include "scalartypes.h"
View
2 numpy/core/src/multiarray/hashdescr.c
@@ -6,7 +6,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "hashdescr.h"
View
2 numpy/core/src/multiarray/item_selection.c
@@ -11,7 +11,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "common.h"
#include "arrayobject.h"
View
2 numpy/core/src/multiarray/iterators.c
@@ -9,7 +9,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "arrayobject.h"
#include "iterators.h"
View
2 numpy/core/src/multiarray/mapping.c
@@ -9,7 +9,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "common.h"
#include "iterators.h"
View
2 numpy/core/src/multiarray/methods.c
@@ -10,7 +10,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "common.h"
#include "ctors.h"
View
2 numpy/core/src/multiarray/multiarray_tests.c.src
@@ -2,7 +2,7 @@
#include <Python.h>
#include "numpy/arrayobject.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
/*
* TODO:
View
2 numpy/core/src/multiarray/multiarraymodule.c
@@ -27,7 +27,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
NPY_NO_EXPORT int NPY_NUMUSERTYPES = 0;
View
2 numpy/core/src/multiarray/na_mask.c
@@ -15,7 +15,7 @@
#include <numpy/arrayobject.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "shape.h"
#include "lowlevel_strided_loops.h"
View
2 numpy/core/src/multiarray/na_object.c
@@ -16,7 +16,7 @@
#include <numpy/arrayscalars.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "descriptor.h"
#include "common.h"
View
2 numpy/core/src/multiarray/nditer_impl.h
@@ -17,7 +17,7 @@
#define NPY_NO_DEPRECATED_API NPY_API_VERSION
#define _MULTIARRAYMODULE
#include <numpy/arrayobject.h>
-#include <numpy/npy_3kcompat.h>
+#include <npy_pycompat.h>
#include "convert_datatype.h"
#include "lowlevel_strided_loops.h"
View
4 numpy/core/src/multiarray/nditer_pywrap.c
@@ -13,11 +13,11 @@
#define NPY_NO_DEPRECATED_API NPY_API_VERSION
#define _MULTIARRAYMODULE
#include <numpy/arrayobject.h>
-#include <numpy/npy_3kcompat.h>
+#include <npy_pycompat.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
typedef struct NewNpyArrayIterObject_tag NewNpyArrayIterObject;
View
2 numpy/core/src/multiarray/number.c
@@ -9,7 +9,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "number.h"
View
2 numpy/core/src/multiarray/numpymemoryview.c
@@ -16,7 +16,7 @@
#include "numpy/arrayscalars.h"
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "numpymemoryview.h"
View
2 numpy/core/src/multiarray/numpyos.c
@@ -11,7 +11,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
/*
* From the C99 standard, section 7.19.6: The exponent always contains at least
View
2 numpy/core/src/multiarray/reduction.c
@@ -15,7 +15,7 @@
#include <numpy/arrayobject.h>
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "lowlevel_strided_loops.h"
#include "na_mask.h"
View
2 numpy/core/src/multiarray/refcount.c
@@ -14,7 +14,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
static void
_fillobject(char *optr, PyObject *obj, PyArray_Descr *dtype);
View
2 numpy/core/src/multiarray/scalarapi.c
@@ -11,7 +11,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "ctors.h"
#include "descriptor.h"
View
2 numpy/core/src/multiarray/scalartypes.c.src
@@ -13,7 +13,7 @@
#include "numpy/halffloat.h"
#include "numpy/arrayscalars.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "npy_config.h"
#include "mapping.h"
View
2 numpy/core/src/multiarray/sequence.c
@@ -9,7 +9,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "common.h"
#include "mapping.h"
View
2 numpy/core/src/multiarray/shape.c
@@ -11,7 +11,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "ctors.h"
View
2 numpy/core/src/multiarray/ucsnarrow.c
@@ -12,7 +12,7 @@
#include "npy_config.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
/*
* Functions only needed on narrow builds of Python for converting back and
View
2 numpy/core/src/multiarray/usertypes.c
@@ -34,7 +34,7 @@ maintainer email: oliphant.travis@ieee.org
#include "common.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "usertypes.h"
View
24 numpy/core/src/private/npy_pycompat.h
@@ -0,0 +1,24 @@
+#ifndef _NPY_PYCOMPAT_H_
+#define _NPY_PYCOMPAT_H_
+
+#include "numpy/npy_3kcompat.h"
+
+/*
+ * Accessing items of ob_base
+ */
+
+#if (PY_VERSION_HEX < 0x02060000)
@charris NumPy member
charris added a note

Aren't these needed for Scipy?

@pv NumPy member
pv added a note

None of them is used in Scipy --- apart from Cython/Swig generated files which have their own versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+#define Py_TYPE(o) (((PyObject*)(o))->ob_type)
+#define Py_REFCNT(o) (((PyObject*)(o))->ob_refcnt)
+#define Py_SIZE(o) (((PyVarObject*)(o))->ob_size)
+#endif
+
+/*
+ * PyIndex_Check
+ */
+#if (PY_VERSION_HEX < 0x02050000)
+#undef PyIndex_Check
+#define PyIndex_Check(o) 0
+#endif
+
+#endif /* _NPY_COMPAT_H_ */
View
2 numpy/core/src/scalarmathmodule.c.src
@@ -13,7 +13,7 @@
#include "numpy/ufuncobject.h"
#include "numpy/arrayscalars.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "numpy/halffloat.h"
View
2 numpy/core/src/umath/funcs.inc.src
@@ -7,7 +7,7 @@
*/
#define NPY_NO_DEPRECATED_API NPY_API_VERSION
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
/*
View
2 numpy/core/src/umath/loops.c.src
@@ -16,7 +16,7 @@
#include "numpy/npy_math.h"
#include "numpy/halffloat.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "ufunc_object.h"
View
2 numpy/core/src/umath/ufunc_object.c
@@ -34,7 +34,7 @@
#define NO_IMPORT_ARRAY
#endif
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
View
2 numpy/core/src/umath/ufunc_type_resolution.c
@@ -19,7 +19,7 @@
#define NO_IMPORT_ARRAY
#endif
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "numpy/ufuncobject.h"
#include "ufunc_type_resolution.h"
View
2 numpy/core/src/umath/umath_tests.c.src
@@ -11,7 +11,7 @@
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
-#include "numpy/npy_3kcompat.h"
+#include "npy_pycompat.h"
#include "npy_config.h"
View
4 numpy/lib/src/_compiled_base.c
@@ -7,6 +7,10 @@
#include "numpy/ufuncobject.h"
#include "string.h"
+#if (PY_VERSION_HEX < 0x02060000)
+#define Py_TYPE(o) (((PyObject*)(o))->ob_type)
+#endif
+
static npy_intp
incr_slot_(double x, double *bins, npy_intp lbins)
{
Something went wrong with that request. Please try again.