Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asanyarray becomes None after re-import np in Embedded mode #12305

Open
algogavin opened this issue Nov 1, 2018 · 2 comments
Open

asanyarray becomes None after re-import np in Embedded mode #12305

algogavin opened this issue Nov 1, 2018 · 2 comments
Labels
00 - Bug 50 - Duplicate Embedded Issues regarding embedded python interpreters

Comments

@algogavin
Copy link

algogavin commented Nov 1, 2018

The issue occurred in the "python embedded mode" only. Basically my C program will create a new python interpreter for each task, the interpreter will execute the python script(that will use numpy there). For the first task, everything runs fine, but then the following tasks, it will throw an error indicating "NoneType object is not callable" and if I debug the script, it happen with it call "np.mean()"(where inside the function, the first function call is "arr=asanyarray(a)", and the asanyarray is set to "None" somehow.[As a comparison, it's not "None" for the first interpreter.]

I verify that for each new interpreter, it will re-import the numpy(among others) modules and did not see any error reported. Also , if I change the code below:

a = ... //an numpy array
b = a.mean(); //this will cause the "None" error

===>
a = ...// an numpy array
a_2 = np.asanyarray( a ); //this is ok!
b = a_2.mean(); // again, "None" error

I suspect there are some initialization routine in numpy.core.numeric was not properly executed when importing, but I don't know how to debug it.

Reproducing code example:

import numpy as np
a = np.array[1.0]
b = a.mean()

Error message:

'NoneType' object is not callable

Numpy/Python version information:

1.15.3

above issue did not occur with numpy 1.6.0 [I have not get a chance to test the numpy package between 1.6 and 1.15]

@algogavin
Copy link
Author

algogavin commented Nov 1, 2018

after reading the release note, it seems in 1.15.1 it mentioned the Cython 0.28.3 had some issues on module initialization, and (should) upgrade to newer Cython, but it's not yet for "safety".

@mattip
Copy link
Member

mattip commented Nov 1, 2018

We don't support numpy re-initialization. For an overview, this search shows 10 issues, some closed with won't-fix, some still open. Maybe when we drop 2.7 support we can hide our global state in a pep 3121 compatible way via PyModule_GetState

@eric-wieser eric-wieser added the Embedded Issues regarding embedded python interpreters label Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 50 - Duplicate Embedded Issues regarding embedded python interpreters
Projects
None yet
Development

No branches or pull requests

3 participants