Commit f384c542 authored by Jason Madden's avatar Jason Madden

Stop using DEF statements in Cython, as they are deprecated.

See https://github.com/cython/cython/issues/4310
parent 2bfebea2
Use a more modern setuptools build backend. There have also been some Use a more modern setuptools build backend.
other build related changes:
- Enable memory leak checking for Python 3.11.
..
TODO: Uncomment this once done
- Stop using the deprecated 'DEF' construct in Cython files. See https://github.com/cython/cython/issues/4310
Stop using the deprecated 'DEF' construct in Cython files. See
https://github.com/cython/cython/issues/4310
Enable memory leak checking for Python 3.11.
...@@ -323,7 +323,13 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback ...@@ -323,7 +323,13 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
def _format(self): def _format(self):
return '' return ''
DEF CALLBACK_CHECK_COUNT = 50 # See comments in cares.pyx about DEF constants and when to use
# what kind.
cdef extern from *:
"""
#define CALLBACK_CHECK_COUNT 50
"""
int CALLBACK_CHECK_COUNT
@cython.final @cython.final
@cython.internal @cython.internal
...@@ -803,19 +809,26 @@ from gevent._interfaces import ICallback ...@@ -803,19 +809,26 @@ from gevent._interfaces import ICallback
classImplements(loop, ILoop) classImplements(loop, ILoop)
classImplements(callback, ICallback) classImplements(callback, ICallback)
# XXX: DEF is deprecated. See _setuputils.py for info.
# about readonly _flags attribute: cdef extern from *:
# bit #1 set if object owns Python reference to itself (Py_INCREF was """
# called and we must call Py_DECREF later) #define FLAG_WATCHER_OWNS_PYREF (1 << 0) /* 0x1 */
DEF FLAG_WATCHER_OWNS_PYREF = 1 << 0 # 0x1 #define FLAG_WATCHER_NEEDS_EVREF (1 << 1) /* 0x2 */
# bit #2 set if ev_unref() was called and we must call ev_ref() later #define FLAG_WATCHER_UNREF_BEFORE_START (1 << 2) /* 0x4 */
DEF FLAG_WATCHER_NEEDS_EVREF = 1 << 1 # 0x2 #define FLAG_WATCHER_MASK_UNREF_NEEDS_REF 0x6
# bit #3 set if user wants to call ev_unref() before start() """
DEF FLAG_WATCHER_UNREF_BEFORE_START = 1 << 2 # 0x4 # about readonly _flags attribute:
# bits 2 and 3 are *both* set when we are active, but the user # bit #1 set if object owns Python reference to itself (Py_INCREF was
# request us not to be ref'd anymore. We unref us (because going active will # called and we must call Py_DECREF later)
# ref us) and then make a note of this in the future unsigned int FLAG_WATCHER_OWNS_PYREF
DEF FLAG_WATCHER_MASK_UNREF_NEEDS_REF = 0x6 # bit #2 set if ev_unref() was called and we must call ev_ref() later
unsigned int FLAG_WATCHER_NEEDS_EVREF
# bit #3 set if user wants to call ev_unref() before start()
unsigned int FLAG_WATCHER_UNREF_BEFORE_START
# bits 2 and 3 are *both* set when we are active, but the user
# request us not to be ref'd anymore. We unref us (because going active will
# ref us) and then make a note of this in the future
unsigned int FLAG_WATCHER_MASK_UNREF_NEEDS_REF
cdef void _python_incref(watcher self): cdef void _python_incref(watcher self):
......
...@@ -35,11 +35,24 @@ else: ...@@ -35,11 +35,24 @@ else:
string_types = __builtins__.basestring, string_types = __builtins__.basestring,
text_type = __builtins__.unicode text_type = __builtins__.unicode
# XXX: DEF is deprecated. See _setuputils.py for info. # These three constants used to be DEF, but the DEF construct
DEF TIMEOUT = 1 # is deprecated in Cython. Using a cdef extern, the generated
# C code refers to the symbol (DEF would have inlined the value).
# That's great when we're strictly in a C context, but for passing to
# Python, it means we do a runtime translation from the C int to the
# Python int. That is avoided if we use a cdef constant. TIMEOUT
# is the only one that interacts with Python, but not in a performance-sensitive
# way, so runtime translation is fine to keep it consistent.
cdef extern from *:
"""
#define TIMEOUT 1
#define EV_READ 1
#define EV_WRITE 2
"""
int TIMEOUT
int EV_READ
int EV_WRITE
DEF EV_READ = 1
DEF EV_WRITE = 2
cdef extern from *: cdef extern from *:
""" """
......
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