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