diff --git a/greenlet.c b/greenlet.c index b858b8de..4934fb94 100644 --- a/greenlet.c +++ b/greenlet.c @@ -98,6 +98,16 @@ The running greenlet's stack_start is undefined but not NULL. } while (0) #endif /* !Py_CLEAR */ +/* Python < 2.4 support */ +#if PY_VERSION_HEX < 0x02040000 +#ifndef Py_RETURN_TRUE +# define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True +#endif +#ifndef Py_RETURN_FALSE +# define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False +#endif +#endif + /* Python <= 2.5 support */ #if PY_MAJOR_VERSION < 3 #ifndef Py_REFCNT @@ -1229,13 +1239,10 @@ static int green_setdict(PyGreenlet* self, PyObject* val, void* c) static PyObject* green_getdead(PyGreenlet* self, void* c) { - PyObject* res; if (PyGreenlet_ACTIVE(self) || !PyGreenlet_STARTED(self)) - res = Py_False; + Py_RETURN_FALSE; else - res = Py_True; - Py_INCREF(res); - return res; + Py_RETURN_TRUE; } static PyObject* green_getrun(PyGreenlet* self, void* c)