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
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
Use a more modern setuptools build backend.
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
def _format(self):
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.internal
......@@ -803,19 +809,26 @@ from gevent._interfaces import ICallback
classImplements(loop, ILoop)
classImplements(callback, ICallback)
# XXX: DEF is deprecated. See _setuputils.py for info.
# about readonly _flags attribute:
# bit #1 set if object owns Python reference to itself (Py_INCREF was
# called and we must call Py_DECREF later)
DEF FLAG_WATCHER_OWNS_PYREF = 1 << 0 # 0x1
# bit #2 set if ev_unref() was called and we must call ev_ref() later
DEF FLAG_WATCHER_NEEDS_EVREF = 1 << 1 # 0x2
# bit #3 set if user wants to call ev_unref() before start()
DEF FLAG_WATCHER_UNREF_BEFORE_START = 1 << 2 # 0x4
# 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
DEF FLAG_WATCHER_MASK_UNREF_NEEDS_REF = 0x6
cdef extern from *:
"""
#define FLAG_WATCHER_OWNS_PYREF (1 << 0) /* 0x1 */
#define FLAG_WATCHER_NEEDS_EVREF (1 << 1) /* 0x2 */
#define FLAG_WATCHER_UNREF_BEFORE_START (1 << 2) /* 0x4 */
#define FLAG_WATCHER_MASK_UNREF_NEEDS_REF 0x6
"""
# about readonly _flags attribute:
# bit #1 set if object owns Python reference to itself (Py_INCREF was
# called and we must call Py_DECREF later)
unsigned int FLAG_WATCHER_OWNS_PYREF
# 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):
......
......@@ -35,11 +35,24 @@ else:
string_types = __builtins__.basestring,
text_type = __builtins__.unicode
# XXX: DEF is deprecated. See _setuputils.py for info.
DEF TIMEOUT = 1
# These three constants used to be DEF, but the DEF construct
# 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 *:
"""
......
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