Mercurial > cpython-lru_cache-weakref
diff Objects/cobject.c @ 53848:7cb6df00699f
#5947: add PendingDeprecationWarning to PyCObject functions.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Wed, 06 May 2009 08:47:56 +0000 |
| parents | 87fbbf22adf3 |
| children |
line wrap: on
line diff
--- a/Objects/cobject.c Wed May 06 08:32:17 2009 +0000 +++ b/Objects/cobject.c Wed May 06 08:47:56 2009 +0000 @@ -9,11 +9,23 @@ typedef void (*destructor1)(void *); typedef void (*destructor2)(void *, void*); + +static int deprecation_exception(void) +{ + return PyErr_WarnEx(PyExc_PendingDeprecationWarning, + "The CObject API is deprecated as of Python 3.1. " + "Please convert to using the Capsule API.", 1); +} + 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 +42,10 @@ { PyCObject *self; + if (deprecation_exception()) { + return NULL; + } + if (!desc) { PyErr_SetString(PyExc_TypeError, "PyCObject_FromVoidPtrAndDesc called with null"
