diff options
-rw-r--r-- | Cython/Utility/MemoryView.pyx | 4 | ||||
-rw-r--r-- | Cython/Utility/MemoryView_C.c | 3 | ||||
-rw-r--r-- | tests/memoryview/memslice.pyx | 6 |
3 files changed, 11 insertions, 2 deletions
diff --git a/Cython/Utility/MemoryView.pyx b/Cython/Utility/MemoryView.pyx index 8fa3c926a..277c0bd87 100644 --- a/Cython/Utility/MemoryView.pyx +++ b/Cython/Utility/MemoryView.pyx @@ -23,7 +23,7 @@ cdef extern from "<string.h>": void *memset(void *b, int c, size_t len) cdef extern from *: - bint CYTHON_ATOMICS + bint __PYX_CYTHON_ATOMICS_ENABLED() noexcept int __Pyx_GetBuffer(object, Py_buffer *, int) except -1 void __Pyx_ReleaseBuffer(Py_buffer *) @@ -352,7 +352,7 @@ cdef class memoryview(object): (<__pyx_buffer *> &self.view).obj = Py_None Py_INCREF(Py_None) - if not CYTHON_ATOMICS: + if not __PYX_CYTHON_ATOMICS_ENABLED(): global __pyx_memoryview_thread_locks_used if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] diff --git a/Cython/Utility/MemoryView_C.c b/Cython/Utility/MemoryView_C.c index 34664f062..1b78b2a4e 100644 --- a/Cython/Utility/MemoryView_C.c +++ b/Cython/Utility/MemoryView_C.c @@ -24,6 +24,9 @@ typedef struct { #ifndef CYTHON_ATOMICS #define CYTHON_ATOMICS 1 #endif +// using CYTHON_ATOMICS as a cdef extern bint in the Cython memoryview code +// interacts badly with "import *". Therefore, define a helper function-like macro +#define __PYX_CYTHON_ATOMICS_ENABLED() CYTHON_ATOMICS #define __pyx_atomic_int_type int diff --git a/tests/memoryview/memslice.pyx b/tests/memoryview/memslice.pyx index ccf760c21..3a5943aa3 100644 --- a/tests/memoryview/memslice.pyx +++ b/tests/memoryview/memslice.pyx @@ -21,6 +21,12 @@ if sys.version_info[0] < 3: else: import builtins +try: + from Cython.Tests.this_module_does_not_exist import * +except ImportError: + # Fails, but the existence of "import *" interacted badly with some utility code + pass + def testcase(func): @wraps(func) |