Commit 67c44be9 authored by da-woods's avatar da-woods Committed by GitHub

Fix error where "import *" tried to overwrite a macro in utility code (GH-4930)

Closes https://github.com/cython/cython/issues/4927
parent 1f719622
...@@ -23,7 +23,7 @@ cdef extern from "<string.h>": ...@@ -23,7 +23,7 @@ cdef extern from "<string.h>":
void *memset(void *b, int c, size_t len) void *memset(void *b, int c, size_t len)
cdef extern from *: cdef extern from *:
bint CYTHON_ATOMICS bint __PYX_CYTHON_ATOMICS_ENABLED() noexcept
int __Pyx_GetBuffer(object, Py_buffer *, int) except -1 int __Pyx_GetBuffer(object, Py_buffer *, int) except -1
void __Pyx_ReleaseBuffer(Py_buffer *) void __Pyx_ReleaseBuffer(Py_buffer *)
...@@ -352,7 +352,7 @@ cdef class memoryview(object): ...@@ -352,7 +352,7 @@ cdef class memoryview(object):
(<__pyx_buffer *> &self.view).obj = Py_None (<__pyx_buffer *> &self.view).obj = Py_None
Py_INCREF(Py_None) Py_INCREF(Py_None)
if not CYTHON_ATOMICS: if not __PYX_CYTHON_ATOMICS_ENABLED():
global __pyx_memoryview_thread_locks_used global __pyx_memoryview_thread_locks_used
if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
......
...@@ -24,6 +24,9 @@ typedef struct { ...@@ -24,6 +24,9 @@ typedef struct {
#ifndef CYTHON_ATOMICS #ifndef CYTHON_ATOMICS
#define CYTHON_ATOMICS 1 #define CYTHON_ATOMICS 1
#endif #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 #define __pyx_atomic_int_type int
......
...@@ -21,6 +21,12 @@ if sys.version_info[0] < 3: ...@@ -21,6 +21,12 @@ if sys.version_info[0] < 3:
else: else:
import builtins 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): def testcase(func):
@wraps(func) @wraps(func)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment