-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[BUG] Access violation using cython.ufunc with cimport numpy #6064
Labels
Milestone
Comments
Adding these lines at the top of the .pyx before any other code seems to work reliable for me: cimport numpy
numpy.import_array()
numpy.import_ufunc() |
So the issue seems to be: using cython/Cython/Utility/NumpyImportArray.c Line 22 in 6aeecde
|
da-woods
added a commit
to da-woods/cython
that referenced
this issue
Mar 9, 2024
Fixes cython#6064. The relevant utility code to set up ufuncs wasn't being included because it compared equal to a different section of utility code that also only contained an init section
da-woods
added a commit
to da-woods/cython
that referenced
this issue
Mar 9, 2024
Fixes cython#6064. The relevant utility code to set up ufuncs wasn't being included because it compared equal to a different section of utility code that also only contained an init section
scoder
pushed a commit
that referenced
this issue
Mar 9, 2024
The relevant utility code to set up ufuncs wasn't being included because it compared equal to a different section of utility code that also only contained an "init" section Fixes #6064
Thank you |
scoder
pushed a commit
that referenced
this issue
Mar 9, 2024
The relevant utility code to set up ufuncs wasn't being included because it compared equal to a different section of utility code that also only contained an "init" section Fixes #6064
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The following code using
@cython.ufunc
, a slight variation of the documentation, crashes reproducibly on import on Windows with Python 3.11/3.12, Cython 3.0.9/3.1.0a0, numpy 1.26.4, Visual Studio 2022, anddefine_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
.The issue might be with when the numpy C API is initialized. For example, the following code does not crash (calling
numpy.import_array()
should not be necessary according to the documentation):However, that is no solution since this does crash on Cython 3.0.9 (seems to be fixed in 3.1.0a0 ?):
I have been using the numpy C API with Cython for many years. This seems to be specific to
cython.ufunc
.Code to reproduce the behaviour:
Expected behaviour
No crash.
OS
Windows 11
Python version
3.11, 3.12
Cython version
3.0.9, 3.1.0a0
Additional context
No response
The text was updated successfully, but these errors were encountered: