diff -r c0cc31c5781c Objects/cobject.c --- a/Objects/cobject.c Tue May 05 15:42:49 2009 -0700 +++ b/Objects/cobject.c Tue May 05 16:43:56 2009 -0700 @@ -9,11 +9,30 @@ typedef void (*destructor1)(void *); typedef void (*destructor2)(void *, void*); + +static int deprecation_exception(void) +{ + static int issued_warning = 0; + if (!issued_warning) { + issued_warning = 1; + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "The CObject API is deprecated as of Python 3.1. " + "Please convert to using the Capsule API.", 1) != 0) { + return 1; + } + } + return 0; +} + PyObject * PyCObject_FromVoidPtr(void *cobj, void (*destr)(void *)) { PyCObject *self; + if (deprecation_exception()) { + return NULL; + } + self = PyObject_NEW(PyCObject, &PyCObject_Type); if (self == NULL) return NULL; @@ -30,6 +49,10 @@ { PyCObject *self; + if (deprecation_exception()) { + return NULL; + } + if (!desc) { PyErr_SetString(PyExc_TypeError, "PyCObject_FromVoidPtrAndDesc called with null"