Index: Include/cobject.h =================================================================== --- Include/cobject.h (revision 84310) +++ Include/cobject.h (working copy) @@ -53,6 +53,11 @@ PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr( void *cobj, void (*destruct)(void*)); +/* Same function, but do not trigger a warning. For internal use. */ + +PyAPI_FUNC(PyObject *) _PyCObject_FromVoidPtr( + void *cobj, void (*destruct)(void*)); + /* Create a PyCObject from a pointer to a C object, a description object, and an optional destructor function. If the third argument is non-null, Index: Objects/cobject.c =================================================================== --- Objects/cobject.c (revision 84310) +++ Objects/cobject.c (working copy) @@ -18,14 +18,10 @@ PyObject * -PyCObject_FromVoidPtr(void *cobj, void (*destr)(void *)) +_PyCObject_FromVoidPtr(void *cobj, void (*destr)(void *)) { PyCObject *self; - if (cobject_deprecation_warning()) { - return NULL; - } - self = PyObject_NEW(PyCObject, &PyCObject_Type); if (self == NULL) return NULL; @@ -37,6 +33,16 @@ } PyObject * +PyCObject_FromVoidPtr(void *cobj, void (*destr)(void *)) +{ + if (cobject_deprecation_warning()) { + return NULL; + } + + return _PyCObject_FromVoidPtr(cobj, destr); +} + +PyObject * PyCObject_FromVoidPtrAndDesc(void *cobj, void *desc, void (*destr)(void *, void *)) { Index: Modules/_bsddb.c =================================================================== --- Modules/_bsddb.c (revision 84310) +++ Modules/_bsddb.c (working copy) @@ -9963,7 +9963,10 @@ ** don't want to break the API compatibility ** for already published Python versions. */ -#if (PY_VERSION_HEX < 0x03020000) +#if (PY_VERSION_HEX > 0x02070000) && (PY_VERSION_HEX < 0x03000000) + /* Non deprecated CObject builder. For internal use. */ + py_api = _PyCObject_FromVoidPtr((void*)&bsddb_api, NULL); +#elif (PY_VERSION_HEX < 0x03020000) py_api = PyCObject_FromVoidPtr((void*)&bsddb_api, NULL); #else { @@ -9976,8 +9979,10 @@ } #endif - PyDict_SetItemString(d, "api", py_api); - Py_DECREF(py_api); + if (py_api) { + PyDict_SetItemString(d, "api", py_api); + Py_DECREF(py_api); + } /* Check for errors */ if (PyErr_Occurred()) {