summaryrefslogtreecommitdiff
path: root/tests/run/numpy_cimport_4.pyx
diff options
context:
space:
mode:
authorda-woods <dw-git@d-woods.co.uk>2020-04-18 21:44:51 +0100
committerGitHub <noreply@github.com>2020-04-18 22:44:51 +0200
commitf18e3c9f9ce35ebf2cf2713775f35c47351e9c15 (patch)
tree02247fd7cada957099f17cbe86f3197608ebb134 /tests/run/numpy_cimport_4.pyx
parent3a3419fb1f13a0ec8ba1121f0aea4e7ec4df4773 (diff)
downloadcython-f18e3c9f9ce35ebf2cf2713775f35c47351e9c15.tar.gz
Make "cimport numpy" without import_array() safer by automatically calling it (GH-3524)
Diffstat (limited to 'tests/run/numpy_cimport_4.pyx')
-rw-r--r--tests/run/numpy_cimport_4.pyx24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/run/numpy_cimport_4.pyx b/tests/run/numpy_cimport_4.pyx
new file mode 100644
index 000000000..44e112054
--- /dev/null
+++ b/tests/run/numpy_cimport_4.pyx
@@ -0,0 +1,24 @@
+# mode: run
+# tag: warnings, numpy
+
+cimport numpy
+<void>numpy.import_array # dummy call should stop Cython auto-generating call to import_array
+
+cdef extern from *:
+ """
+ static void** _check_array_api(void) {
+ return PyArray_API; /* should be non NULL if initialized */
+ }
+ """
+ void** _check_array_api()
+
+def check_array_api():
+ """
+ >>> check_array_api()
+ True
+ """
+ return _check_array_api() == NULL # not initialized
+
+
+_WARNINGS = """
+"""