Skip to content

Commit

Permalink
DEP: Update NPY_NO_DEPRECATED_API to be version-based
Browse files Browse the repository at this point in the history
  • Loading branch information
mwiebe authored and charris committed Apr 6, 2012
1 parent e1218cc commit 64c3be0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
17 changes: 9 additions & 8 deletions numpy/core/include/numpy/ndarraytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions numpy/core/include/numpy/npy_deprecated_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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? */

Expand All @@ -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

Expand Down

0 comments on commit 64c3be0

Please sign in to comment.