Commit 494204d1 authored by Denis Bilenko's avatar Denis Bilenko

fix build problem on Python 2.5

parent f0a41580
...@@ -80,7 +80,7 @@ static void gevent_callback(struct ev_loop *_loop, void *c_watcher, int revents) ...@@ -80,7 +80,7 @@ static void gevent_callback(struct ev_loop *_loop, void *c_watcher, int revents)
/* we use this callback for all watchers, not just timer /* we use this callback for all watchers, not just timer
* we can do this, because layout of struct members is the same for all watchers */ * we can do this, because layout of struct members is the same for all watchers */
watcher = ((struct PyGeventTimerObject *)(((char *)c_watcher) - timer_offsetof)); watcher = ((struct PyGeventTimerObject *)(((char *)c_watcher) - timer_offsetof));
Py_INCREF(watcher); Py_INCREF((PyObject*)watcher);
gevent_check_signals(watcher->loop); gevent_check_signals(watcher->loop);
args = watcher->args; args = watcher->args;
if (args == Py_None) { if (args == Py_None) {
...@@ -126,7 +126,7 @@ static void gevent_callback(struct ev_loop *_loop, void *c_watcher, int revents) ...@@ -126,7 +126,7 @@ static void gevent_callback(struct ev_loop *_loop, void *c_watcher, int revents)
gevent_stop(watcher); gevent_stop(watcher);
} }
end: end:
Py_DECREF(watcher); Py_DECREF((PyObject*)watcher);
GIL_RELEASE; GIL_RELEASE;
} }
......
...@@ -175,7 +175,7 @@ cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent ...@@ -175,7 +175,7 @@ cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent
cdef ares_channel channel cdef ares_channel channel
cdef object callback cdef object callback
channel, callback = <tuple>arg channel, callback = <tuple>arg
Py_DECREF(arg) Py_DECREF(<PyObjectPtr>arg)
cdef object host_result cdef object host_result
try: try:
if status or not host: if status or not host:
...@@ -195,7 +195,7 @@ cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, cha ...@@ -195,7 +195,7 @@ cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, cha
cdef ares_channel channel cdef ares_channel channel
cdef object callback cdef object callback
channel, callback = <tuple>arg channel, callback = <tuple>arg
Py_DECREF(arg) Py_DECREF(<PyObjectPtr>arg)
cdef object node cdef object node
cdef object service cdef object service
try: try:
...@@ -358,7 +358,7 @@ cdef public class ares_channel [object PyGeventAresChannelObject, type PyGeventA ...@@ -358,7 +358,7 @@ cdef public class ares_channel [object PyGeventAresChannelObject, type PyGeventA
# behaves the same as AS_UNSPEC # behaves the same as AS_UNSPEC
# note that for file lookups still AF_INET can be returned for AF_INET6 request # note that for file lookups still AF_INET can be returned for AF_INET6 request
cdef object arg = (self, callback) cdef object arg = (self, callback)
Py_INCREF(<void*>arg) Py_INCREF(<PyObjectPtr>arg)
cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg) cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg)
def gethostbyaddr(self, object callback, char* addr): def gethostbyaddr(self, object callback, char* addr):
...@@ -378,7 +378,7 @@ cdef public class ares_channel [object PyGeventAresChannelObject, type PyGeventA ...@@ -378,7 +378,7 @@ cdef public class ares_channel [object PyGeventAresChannelObject, type PyGeventA
callback(result(exception=ValueError('illegal IP address string: %r' % addr))) callback(result(exception=ValueError('illegal IP address string: %r' % addr)))
return return
cdef object arg = (self, callback) cdef object arg = (self, callback)
Py_INCREF(<void*>arg) Py_INCREF(<PyObjectPtr>arg)
cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg) cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg)
cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags):
...@@ -400,7 +400,7 @@ cdef public class ares_channel [object PyGeventAresChannelObject, type PyGeventA ...@@ -400,7 +400,7 @@ cdef public class ares_channel [object PyGeventAresChannelObject, type PyGeventA
callback(result(exception=ValueError('illegal IP address string: %r' % hostp))) callback(result(exception=ValueError('illegal IP address string: %r' % hostp)))
return return
cdef object arg = (self, callback) cdef object arg = (self, callback)
Py_INCREF(<void*>arg) Py_INCREF(<PyObjectPtr>arg)
cares.ares_getnameinfo(self.channel, &sa6, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg) cares.ares_getnameinfo(self.channel, &sa6, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg)
def getnameinfo(self, object callback, tuple sockaddr, int flags): def getnameinfo(self, object callback, tuple sockaddr, int flags):
......
...@@ -13,18 +13,21 @@ __all__ = ['get_version', ...@@ -13,18 +13,21 @@ __all__ = ['get_version',
cdef extern from "Python.h": cdef extern from "Python.h":
void Py_INCREF(void*) struct PyObject:
void Py_DECREF(void*) pass
void Py_XDECREF(void*) ctypedef PyObject* PyObjectPtr "PyObject*"
int Py_ReprEnter(void*) void Py_INCREF(PyObjectPtr)
void Py_ReprLeave(void*) void Py_DECREF(PyObjectPtr)
int PyCallable_Check(void*) void Py_XDECREF(PyObjectPtr)
int Py_ReprEnter(PyObjectPtr)
void Py_ReprLeave(PyObjectPtr)
int PyCallable_Check(PyObjectPtr)
cdef extern from "frameobject.h": cdef extern from "frameobject.h":
ctypedef struct PyThreadState: ctypedef struct PyThreadState:
void* exc_type PyObjectPtr exc_type
void* exc_value PyObjectPtr exc_value
void* exc_traceback PyObjectPtr exc_traceback
PyThreadState* PyThreadState_GET() PyThreadState* PyThreadState_GET()
cdef extern from "callbacks.h": cdef extern from "callbacks.h":
...@@ -370,7 +373,7 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]: ...@@ -370,7 +373,7 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
define(INCREF, ``if self._incref == 0: define(INCREF, ``if self._incref == 0:
self._incref = 1 self._incref = 1
Py_INCREF(<void*>self)'') Py_INCREF(<PyObjectPtr>self)'')
define(WATCHER_BASE, `cdef public loop loop define(WATCHER_BASE, `cdef public loop loop
...@@ -385,7 +388,7 @@ define(WATCHER_BASE, `cdef public loop loop ...@@ -385,7 +388,7 @@ define(WATCHER_BASE, `cdef public loop loop
return self._callback return self._callback
def __set__(self, object callback): def __set__(self, object callback):
if not PyCallable_Check(<void*>callback): if not PyCallable_Check(<PyObjectPtr>callback):
raise TypeError("Expected callable, not %r" % callback) raise TypeError("Expected callable, not %r" % callback)
self._callback = callback self._callback = callback
...@@ -397,7 +400,7 @@ define(WATCHER_BASE, `cdef public loop loop ...@@ -397,7 +400,7 @@ define(WATCHER_BASE, `cdef public loop loop
self._callback = None self._callback = None
self.args = None self.args = None
if self._incref == 1: if self._incref == 1:
Py_DECREF(<void*>self) Py_DECREF(<PyObjectPtr>self)
self._incref = 0 self._incref = 0
property pending: property pending:
...@@ -464,7 +467,7 @@ cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Ty ...@@ -464,7 +467,7 @@ cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Ty
"""Abstract base class for all the watchers""" """Abstract base class for all the watchers"""
def __repr__(self): def __repr__(self):
if Py_ReprEnter(<void*>self) != 0: if Py_ReprEnter(<PyObjectPtr>self) != 0:
return "<...>" return "<...>"
try: try:
format = self._format() format = self._format()
...@@ -483,7 +486,7 @@ cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Ty ...@@ -483,7 +486,7 @@ cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Ty
result += " _incref=%s" % self._incref result += " _incref=%s" % self._incref
return result + ">" return result + ">"
finally: finally:
Py_ReprLeave(<void*>self) Py_ReprLeave(<PyObjectPtr>self)
def _format(self): def _format(self):
return '' return ''
...@@ -613,19 +616,19 @@ cdef public class callback(watcher) [object PyGeventCallbackObject, type PyGeven ...@@ -613,19 +616,19 @@ cdef public class callback(watcher) [object PyGeventCallbackObject, type PyGeven
def set_exc_info(object type, object value): def set_exc_info(object type, object value):
cdef PyThreadState* tstate = PyThreadState_GET() cdef PyThreadState* tstate = PyThreadState_GET()
Py_XDECREF(<void*>tstate.exc_type) Py_XDECREF(tstate.exc_type)
Py_XDECREF(<void*>tstate.exc_value) Py_XDECREF(tstate.exc_value)
Py_XDECREF(<void*>tstate.exc_traceback) Py_XDECREF(tstate.exc_traceback)
if type is None: if type is None:
tstate.exc_type = NULL tstate.exc_type = NULL
else: else:
Py_INCREF(<void*>type) Py_INCREF(<PyObjectPtr>type)
tstate.exc_type = <void*>type tstate.exc_type = <PyObjectPtr>type
if value is None: if value is None:
tstate.exc_value = NULL tstate.exc_value = NULL
else: else:
Py_INCREF(<void*>value) Py_INCREF(<PyObjectPtr>value)
tstate.exc_value = <void *>value tstate.exc_value = <PyObjectPtr>value
tstate.exc_traceback = NULL tstate.exc_traceback = NULL
......
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