Commits

Georg Brandl  committed 7cb6df0

#5947: add PendingDeprecationWarning to PyCObject functions.

  • Participants
  • Parent commits df3f5db

Comments (0)

Files changed (1)

File Objects/cobject.c

 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;
 {
     PyCObject *self;
 
+    if (deprecation_exception()) {
+        return NULL;
+    }
+
     if (!desc) {
         PyErr_SetString(PyExc_TypeError,
                         "PyCObject_FromVoidPtrAndDesc called with null"