diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2012-02-04 16:51:44 -0800 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2012-04-06 15:54:30 -0600 |
commit | 64c3be01cd18d1cab9cefaa5fa5cd8f78fda761e (patch) | |
tree | b48f1eddafec54ef85a832ffec88365ac76c65e5 | |
parent | e1218cc68ddab6b806628877de19394616df04f7 (diff) | |
download | numpy-64c3be01cd18d1cab9cefaa5fa5cd8f78fda761e.tar.gz |
DEP: Update NPY_NO_DEPRECATED_API to be version-based
-rw-r--r-- | numpy/core/include/numpy/ndarraytypes.h | 17 | ||||
-rw-r--r-- | numpy/core/include/numpy/npy_deprecated_api.h | 6 |
2 files changed, 12 insertions, 11 deletions
diff --git a/numpy/core/include/numpy/ndarraytypes.h b/numpy/core/include/numpy/ndarraytypes.h index 3f224b4e7..ec890f87d 100644 --- a/numpy/core/include/numpy/ndarraytypes.h +++ b/numpy/core/include/numpy/ndarraytypes.h @@ -623,7 +623,8 @@ typedef struct _arr_descr { * (PyArray_DATA and friends) to access fields here for a number of * releases. Direct access to the members themselves is deprecated. * To ensure that your code does not use deprecated access, - * #define NPY_NO_DEPRECATED_API. + * #define NPY_NO_DEPRECATED_API NPY_1_7_VERSION + * (or NPY_1_8_VERSION or higher as required). */ /* This struct will be moved to a private header in a future release */ typedef struct tagPyArrayObject_fields { @@ -692,16 +693,16 @@ typedef struct tagPyArrayObject_fields { * To hide the implementation details, we only expose * the Python struct HEAD. */ -#ifdef NPY_NO_DEPRECATED_API -typedef struct tagPyArrayObject { - PyObject_HEAD -} PyArrayObject; -#else +#if !(defined(NPY_NO_DEPRECATED_API) && (NPY_API_VERSION <= NPY_NO_DEPRECATED_API)) /* * Can't put this in npy_deprecated_api.h like the others. * PyArrayObject field access is deprecated as of NumPy 1.7. */ typedef PyArrayObject_fields PyArrayObject; +#else +typedef struct tagPyArrayObject { + PyObject_HEAD +} PyArrayObject; #endif #define NPY_SIZEOF_PYARRAYOBJECT (sizeof(PyArrayObject_fields)) @@ -1432,7 +1433,7 @@ PyArrayNeighborhoodIter_Next2D(PyArrayNeighborhoodIterObject* iter); #define PyArray_FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS) ? \ NPY_ARRAY_F_CONTIGUOUS : 0)) -#ifdef NPY_NO_DEPRECATED_API +#if (defined(NPY_NO_DEPRECATED_API) && (NPY_API_VERSION <= NPY_NO_DEPRECATED_API)) /* * Changing access macros into functions, to allow for future hiding * of the internal memory layout. This later hiding will allow the 2.x series @@ -1968,7 +1969,7 @@ typedef struct { */ } PyArrayInterface; -#ifndef NPY_NO_DEPRECATED_API +#if !(defined(NPY_NO_DEPRECATED_API) && (NPY_API_VERSION <= NPY_NO_DEPRECATED_API)) #include "npy_deprecated_api.h" #endif diff --git a/numpy/core/include/numpy/npy_deprecated_api.h b/numpy/core/include/numpy/npy_deprecated_api.h index 29bdd95c4..2fab2cd0d 100644 --- a/numpy/core/include/numpy/npy_deprecated_api.h +++ b/numpy/core/include/numpy/npy_deprecated_api.h @@ -6,9 +6,9 @@ #define _WARN___STR1__(x) _WARN___STR2__(x) #define _WARN___LOC__ __FILE__ "("_WARN___STR1__(__LINE__)") : Warning Msg: " #pragma message(_WARN___LOC__"Using deprecated NumPy API, disable it by " \ - "#defining NPY_NO_DEPRECATED_API") + "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION") #elif defined(__GNUC__) -#warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API" +#warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" #endif /* TODO: How to do this warning message for other compilers? */ @@ -19,7 +19,7 @@ * and namespace pollution currently produced by the NumPy headers. */ -#ifdef NPY_NO_DEPRECATED_API +#if defined(NPY_NO_DEPRECATED_API) #error Should never include npy_deprecated_api directly. #endif |