diff options
author | Georg Brandl <georg@python.org> | 2009-05-06 08:47:56 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-05-06 08:47:56 (GMT) |
commit | 5776c1623c1d14b8624547db5755fec8d60fc8ed (patch) | |
tree | d93f2356b832f0f0b1d45544a5ce1b08c3d0bb8f /Objects | |
parent | 30f4a4c50517e551ed1af2a2b9e817ef3e667656 (diff) | |
download | cpython-5776c1623c1d14b8624547db5755fec8d60fc8ed.zip cpython-5776c1623c1d14b8624547db5755fec8d60fc8ed.tar.gz cpython-5776c1623c1d14b8624547db5755fec8d60fc8ed.tar.bz2 |
#5947: add PendingDeprecationWarning to PyCObject functions.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/cobject.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Objects/cobject.c b/Objects/cobject.c index e9b71df..a692150 100644 --- a/Objects/cobject.c +++ b/Objects/cobject.c @@ -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_FromVoidPtrAndDesc(void *cobj, void *desc, { PyCObject *self; + if (deprecation_exception()) { + return NULL; + } + if (!desc) { PyErr_SetString(PyExc_TypeError, "PyCObject_FromVoidPtrAndDesc called with null" |