Compatibility with Python 2.3

This commit is contained in:
rdb 2008-11-30 13:22:34 +00:00
parent 89c0c5d5ff
commit 227c7c3497
2 changed files with 22 additions and 1 deletions

View File

@ -64,6 +64,25 @@ typedef int Py_ssize_t;
#endif // PY_VERSION_HEX
// 2.4 macros which aren't available in 2.3
#ifndef Py_RETURN_NONE
inline PyObject* doPy_RETURN_NONE()
{ Py_INCREF(Py_None); return Py_None; }
#define Py_RETURN_NONE return doPy_RETURN_NONE()
#endif
#ifndef Py_RETURN_TRUE
inline PyObject* doPy_RETURN_TRUE()
{Py_INCREF(Py_True); return Py_True;}
#define Py_RETURN_TRUE return doPy_RETURN_TRUE()
#endif
#ifndef Py_RETURN_FALSE
inline PyObject* doPy_RETURN_FALSE()
{Py_INCREF(Py_False); return Py_False;}
#define Py_RETURN_FALSE return doPy_RETURN_FALSE()
#endif
using namespace std;
#define PY_PANDA_SMALLER_FOOTPRINT 1

View File

@ -378,6 +378,7 @@ do_python_task() {
Thread::get_current_thread()->call_python_func(_function, args);
Py_DECREF(args);
#ifdef PyGen_Check
if (result != (PyObject *)NULL && PyGen_Check(result)) {
// The function has yielded a generator. We will call into that
// henceforth, instead of calling the function from the top
@ -392,6 +393,7 @@ do_python_task() {
_generator = result;
result = NULL;
}
#endif
}
if (_generator != (PyObject *)NULL) {
@ -597,7 +599,7 @@ call_function(PyObject *function) {
PyObject *self =
DTool_CreatePyInstanceTyped(this, Dtool_TypedReferenceCount,
true, false, get_type_index());
PyObject *args = PyTuple_Pack(1, self);
PyObject *args = Py_BuildValue("(O)", self);
Py_DECREF(self);
PyObject *result = PyObject_CallObject(function, args);