[SciPy-user] bug with NO_IMPORT_ARRAY / PY_ARRAY_UNIQUE_SYMBOL? was Re: segfault when calling PyArray_DescrFromType
martin.wiechert at gmx.de
Sat Feb 11 12:42:50 CST 2006
thanks for your help!
I think there is a small bug with NO_IMPORT_ARRAY / PY_ARRAY_UNIQUE_SYMBOL in
numpy-0.9.4. For ease of reference I've pasted part of __multiarray_api.h
The problem I ran into is, that my "non-importing" source files, the ones
defining NO_IMPORT_ARRAY, cannot see PyArray_API, because they obviously
cannot know which name I chose in the importing file.
E.g. I do
#define PY_ARRAY_UNIQUE_SYMBOL my_name
in the file which calls import_array (). Then the object generated will not
have the symbol PyArray_API, because PyArray_API is replaced with my_name.
But the sources with NO_IMPORT_ARRAY look for PyArray_API, because for them it
is not replaced. Indeed inserting
#define PyArray_API my_name
into these files seems to fix the problem for me.
#define PyArray_API PY_ARRAY_UNIQUE_SYMBOL
#if defined(NO_IMPORT) || defined(NO_IMPORT_ARRAY)
extern void **PyArray_API;
static void **PyArray_API=NULL;
On Thursday 09 February 2006 16:48, Travis Oliphant wrote:
> Martin Wiechert wrote:
> >Found it (in the "old" docs).
> >Must #define PY_ARRAY_UNIQUE_SYMBOL and call import_array ().
> To be clear, you must call import_array() in the modules init function.
> This is the only requirement.
> You only have to define PY_ARRAY_UNIQUE_SYMBOL if your extension module
> uses more than one file. In the files without the module initialization
> code you also have to define NO_IMPORT_ARRAY.
More information about the SciPy-user