[Python-checkins] r61082 - python/trunk/Modules/gdbmmodule.c
christian.heimes
python-checkins at python.org
Tue Feb 26 09:18:12 CET 2008
Author: christian.heimes
Date: Tue Feb 26 09:18:11 2008
New Revision: 61082
Modified:
python/trunk/Modules/gdbmmodule.c
Log:
The contains function raised a gcc warning. The new code is copied straight from py3k.
Modified: python/trunk/Modules/gdbmmodule.c
==============================================================================
--- python/trunk/Modules/gdbmmodule.c (original)
+++ python/trunk/Modules/gdbmmodule.c Tue Feb 26 09:18:11 2008
@@ -179,16 +179,23 @@
}
static int
-dbm_contains(register dbmobject *dp, PyObject *v)
+dbm_contains(register dbmobject *dp, PyObject *arg)
{
datum key;
- if (PyString_AsStringAndSize(v, &key.dptr, &key.dsize)) {
+ if ((dp)->di_dbm == NULL) {
+ PyErr_SetString(DbmError,
+ "GDBM object has already been closed");
return -1;
}
-
- check_dbmobject_open(dp);
-
+ if (!PyString_Check(arg)) {
+ PyErr_Format(PyExc_TypeError,
+ "gdbm key must be string, not %.100s",
+ arg->ob_type->tp_name);
+ return -1;
+ }
+ key.dptr = PyString_AS_STRING(arg);
+ key.dsize = PyString_GET_SIZE(arg);
return gdbm_exists(dp->di_dbm, key);
}
More information about the Python-checkins
mailing list