#undef HAVE_WARNINGS
#endif
+#if PYTHON_API_VERSION <= 1007
+ /* 1.5 compatibility */
+#define PyObject_New PyObject_NEW
+#define PyObject_Del PyMem_DEL
+#endif
+
struct behaviourFlags {
/* What is the default behaviour when DB->get or DBCursor->get returns a
DB_NOTFOUND error? Return None or raise an exception? */
DB_ENV* db_env = NULL;
int err;
-#if PYTHON_API_VERSION <= 1007
- /* 1.5 compatibility */
- self = PyObject_NEW(DBObject, &DB_Type);
-#else
self = PyObject_New(DBObject, &DB_Type);
-#endif
-
if (self == NULL)
return NULL;
self->associateCallback = NULL;
}
#endif
-#if PYTHON_API_VERSION <= 1007
- PyMem_DEL(self);
-#else
PyObject_Del(self);
-#endif
}
static DBCursorObject*
newDBCursorObject(DBC* dbc, DBObject* db)
{
- DBCursorObject* self;
-#if PYTHON_API_VERSION <= 1007
- self = PyObject_NEW(DBCursorObject, &DBCursor_Type);
-#else
- self = PyObject_New(DBCursorObject, &DBCursor_Type);
-#endif
+ DBCursorObject* self = PyObject_New(DBCursorObject, &DBCursor_Type);
if (self == NULL)
return NULL;
MYDB_END_ALLOW_THREADS;
}
Py_XDECREF( self->mydb );
-#if PYTHON_API_VERSION <= 1007
- PyMem_DEL(self);
-#else
PyObject_Del(self);
-#endif
}
newDBEnvObject(int flags)
{
int err;
- DBEnvObject* self;
-#if PYTHON_API_VERSION <= 1007
- self = PyObject_NEW(DBEnvObject, &DBEnv_Type);
-#else
- self = PyObject_New(DBEnvObject, &DBEnv_Type);
-#endif
-
+ DBEnvObject* self = PyObject_New(DBEnvObject, &DBEnv_Type);
if (self == NULL)
return NULL;
self->db_env->close(self->db_env, 0);
MYDB_END_ALLOW_THREADS;
}
-#if PYTHON_API_VERSION <= 1007
- PyMem_DEL(self);
-#else
PyObject_Del(self);
-#endif
}
newDBTxnObject(DBEnvObject* myenv, DB_TXN *parent, int flags)
{
int err;
- DBTxnObject* self;
-
-#if PYTHON_API_VERSION <= 1007
- self = PyObject_NEW(DBTxnObject, &DBTxn_Type);
-#else
- self = PyObject_New(DBTxnObject, &DBTxn_Type);
-#endif
+ DBTxnObject* self = PyObject_New(DBTxnObject, &DBTxn_Type);
if (self == NULL)
return NULL;
#ifdef HAVE_WEAKREF
}
#endif
-#if PYTHON_API_VERSION <= 1007
- PyMem_DEL(self);
-#else
PyObject_Del(self);
-#endif
}
db_lockmode_t lock_mode, int flags)
{
int err;
- DBLockObject* self;
-
-#if PYTHON_API_VERSION <= 1007
- self = PyObject_NEW(DBLockObject, &DBLock_Type);
-#else
- self = PyObject_New(DBLockObject, &DBLock_Type);
-#endif
+ DBLockObject* self = PyObject_New(DBLockObject, &DBLock_Type);
if (self == NULL)
return NULL;
#ifdef HAVE_WEAKREF
#endif
/* TODO: is this lock held? should we release it? */
-#if PYTHON_API_VERSION <= 1007
- PyMem_DEL(self);
-#else
PyObject_Del(self);
-#endif
}