maintain support for older python versions in this module so that it

is ok for a standalone pybsddb source dist for use with <= 2.3.
This commit is contained in:
Gregory P. Smith 2006-01-30 00:22:08 +00:00
parent c26cf5a6f1
commit fd049a696d
1 changed files with 16 additions and 0 deletions

View File

@ -1537,11 +1537,19 @@ DB_pget(DBObject* self, PyObject* args, PyObject* kwargs)
keyObj = PyInt_FromLong(*(int *)key.data); keyObj = PyInt_FromLong(*(int *)key.data);
else else
keyObj = PyString_FromStringAndSize(key.data, key.size); keyObj = PyString_FromStringAndSize(key.data, key.size);
#if (PY_VERSION_HEX >= 0x02040000)
retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj); retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj);
#else
retval = Py_BuildValue("OOO", keyObj, pkeyObj, dataObj);
#endif
} }
else /* return just the pkey and data */ else /* return just the pkey and data */
{ {
#if (PY_VERSION_HEX >= 0x02040000)
retval = PyTuple_Pack(2, pkeyObj, dataObj); retval = PyTuple_Pack(2, pkeyObj, dataObj);
#else
retval = Py_BuildValue("OO", pkeyObj, dataObj);
#endif
} }
FREE_DBT(pkey); FREE_DBT(pkey);
FREE_DBT(data); FREE_DBT(data);
@ -3187,12 +3195,20 @@ DBC_pget(DBCursorObject* self, PyObject* args, PyObject *kwargs)
keyObj = PyInt_FromLong(*(int *)key.data); keyObj = PyInt_FromLong(*(int *)key.data);
else else
keyObj = PyString_FromStringAndSize(key.data, key.size); keyObj = PyString_FromStringAndSize(key.data, key.size);
#if (PY_VERSION_HEX >= 0x02040000)
retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj); retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj);
#else
retval = Py_BuildValue("OOO", keyObj, pkeyObj, dataObj);
#endif
FREE_DBT(key); FREE_DBT(key);
} }
else /* return just the pkey and data */ else /* return just the pkey and data */
{ {
#if (PY_VERSION_HEX >= 0x02040000)
retval = PyTuple_Pack(2, pkeyObj, dataObj); retval = PyTuple_Pack(2, pkeyObj, dataObj);
#else
retval = Py_BuildValue("OO", pkeyObj, dataObj);
#endif
} }
FREE_DBT(pkey); FREE_DBT(pkey);
FREE_DBT(data); FREE_DBT(data);