summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2007-08-23 07:32:27 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2007-08-23 07:32:27 (GMT)
commit361ed15383845bffc017b6a14acfb9da8f63ef73 (patch)
tree808d7729ad334a8b32e31fca6acd1edf010d7398 /Modules
parente5a8dc684ce67578f1bac94c1a76fea659d4ace7 (diff)
downloadcpython-361ed15383845bffc017b6a14acfb9da8f63ef73.zip
cpython-361ed15383845bffc017b6a14acfb9da8f63ef73.tar.gz
cpython-361ed15383845bffc017b6a14acfb9da8f63ef73.tar.bz2
Require strict bytes objects for all bsddb.db input values.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_bsddb.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index 149cd98..389b103 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -380,11 +380,13 @@ static int make_dbt(PyObject* obj, DBT* dbt)
if (obj == Py_None) {
/* no need to do anything, the structure has already been zeroed */
}
- else if (!PyArg_Parse(obj, "s#", &dbt->data, &dbt->size)) {
+ else if (!PyBytes_Check(obj)) {
PyErr_SetString(PyExc_TypeError,
- "Data values must be of type string or None.");
+ "Data values must be of type bytes or None.");
return 0;
}
+ dbt->data = PyBytes_AS_STRING(obj);
+ dbt->size = PyBytes_GET_SIZE(obj);
return 1;
}
@@ -4737,7 +4739,7 @@ DBTxn_prepare(DBTxnObject* self, PyObject* args)
char* gid=NULL;
int gid_size=0;
- if (!PyArg_ParseTuple(args, "s#:prepare", &gid, &gid_size))
+ if (!PyArg_ParseTuple(args, "y#:prepare", &gid, &gid_size))
return NULL;
if (gid_size != DB_XIDDATASIZE) {
@@ -5915,6 +5917,7 @@ PyMODINIT_FUNC init_bsddb(void)
#if (DBVER >= 33)
ADD_INT(d, DB_DONOTINDEX);
+ ADD_INT(d, DB_XIDDATASIZE);
#endif
#if (DBVER >= 41)