Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd049a6

Browse files
committed
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.
1 parent c26cf5a commit fd049a6

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Modules/_bsddb.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,11 +1537,19 @@ DB_pget(DBObject* self, PyObject* args, PyObject* kwargs)
15371537
keyObj = PyInt_FromLong(*(int *)key.data);
15381538
else
15391539
keyObj = PyString_FromStringAndSize(key.data, key.size);
1540+
#if (PY_VERSION_HEX >= 0x02040000)
15401541
retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj);
1542+
#else
1543+
retval = Py_BuildValue("OOO", keyObj, pkeyObj, dataObj);
1544+
#endif
15411545
}
15421546
else /* return just the pkey and data */
15431547
{
1548+
#if (PY_VERSION_HEX >= 0x02040000)
15441549
retval = PyTuple_Pack(2, pkeyObj, dataObj);
1550+
#else
1551+
retval = Py_BuildValue("OO", pkeyObj, dataObj);
1552+
#endif
15451553
}
15461554
FREE_DBT(pkey);
15471555
FREE_DBT(data);
@@ -3187,12 +3195,20 @@ DBC_pget(DBCursorObject* self, PyObject* args, PyObject *kwargs)
31873195
keyObj = PyInt_FromLong(*(int *)key.data);
31883196
else
31893197
keyObj = PyString_FromStringAndSize(key.data, key.size);
3198+
#if (PY_VERSION_HEX >= 0x02040000)
31903199
retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj);
3200+
#else
3201+
retval = Py_BuildValue("OOO", keyObj, pkeyObj, dataObj);
3202+
#endif
31913203
FREE_DBT(key);
31923204
}
31933205
else /* return just the pkey and data */
31943206
{
3207+
#if (PY_VERSION_HEX >= 0x02040000)
31953208
retval = PyTuple_Pack(2, pkeyObj, dataObj);
3209+
#else
3210+
retval = Py_BuildValue("OO", pkeyObj, dataObj);
3211+
#endif
31963212
}
31973213
FREE_DBT(pkey);
31983214
FREE_DBT(data);

0 commit comments

Comments
 (0)