]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#5947: add PendingDeprecationWarning to PyCObject functions.
authorGeorg Brandl <georg@python.org>
Wed, 6 May 2009 08:47:56 +0000 (08:47 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 6 May 2009 08:47:56 +0000 (08:47 +0000)
Objects/cobject.c

index e9b71df58c2641e70556f2347dd4cbf470b6444d..a69215021d2c8e239a7281c48bd502efc5abe50b 100644 (file)
@@ -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"